Created
November 7, 2014 13:34
-
-
Save nima/1f44b988148a8a352d6f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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])) |
Author
nima
commented
Nov 7, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment