Created
January 29, 2016 20:26
-
-
Save negator/580ea1340932d24352e6 to your computer and use it in GitHub Desktop.
blum secure password algorithm
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
import string | |
import re | |
alpha = raw_input('alpha: ') | |
seq = raw_input('seq: ') | |
name = raw_input('text: ') | |
seq = map(int, list(seq.replace(" ",""))) | |
f = dict(zip(list(string.ascii_lowercase), map(int, list(alpha.replace(" ",""))))) | |
g = lambda n: seq[(n + 1) % 10] | |
cipher = map(f.get, re.sub(r'[^a-z]', "",name)) | |
b = (cipher[0] + cipher[len(cipher)-1]) % 10 | |
print reduce(lambda x,y: x + [g(x[len(x) -1] +y) % 10], cipher[1::], [b]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment