Skip to content

Instantly share code, notes, and snippets.

@nima
Created November 7, 2014 13:34
Show Gist options
  • Save nima/1f44b988148a8a352d6f to your computer and use it in GitHub Desktop.
Save nima/1f44b988148a8a352d6f to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
def encrypt(x):
return [((a+1)*ord(b)%256) for a,b in zip(range(len(x)), x)]
def decrypt(a):
for i in range(len(a)):
while not (a[i] % (i+1) == 0 and a[i]/(i+1) in range(48,123)):
a[i] += 256
a[i] /= (i+1)
return ''.join([chr(_) for _ in a])
import sys
if len(sys.argv) == 7:
print(decrypt([int(_) for _ in sys.argv[1:]]))
elif len(sys.argv) == 2:
print(encrypt(sys.argv[1]))
@nima
Copy link
Author

nima commented Nov 7, 2014

$ ./foo.py 50 194 162 148 93 94
2a6eye

$ ./foo.py 2a6eye
[50, 194, 162, 148, 93, 94]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment