Skip to content

Instantly share code, notes, and snippets.

@negator
Created January 29, 2016 20:26
Show Gist options
  • Save negator/580ea1340932d24352e6 to your computer and use it in GitHub Desktop.
Save negator/580ea1340932d24352e6 to your computer and use it in GitHub Desktop.
blum secure password algorithm
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