Skip to content

Instantly share code, notes, and snippets.

@Brick85
Created April 11, 2016 07:51
Show Gist options
  • Save Brick85/60c668c31e09aedce58b994275e01e93 to your computer and use it in GitHub Desktop.
Save Brick85/60c668c31e09aedce58b994275e01e93 to your computer and use it in GitHub Desktop.
# http://stackoverflow.com/questions/21986602/fixed-length-int-obfuscator-does-anyone-know-how-to-do-this
class IntObfuscator(object):
m = 1000000000
x = 387420489
inverseX = 513180409
def encode_int(self, value):
return value * self.x % self.m
def decode_int(self, encoded):
return encoded * self.inverseX % self.m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment