Playfair cipher: Difference between revisions

m
Line 1,120:
# Translate key into an encoding 5x5 translation matrix.
keyletters = unique([c for c in canonical(key * "ABCDEFGHIJKLMNOPQRSTUVWXYZ")])
 
m = reshape(keyletters[1:25], 5, 5)
 
# encod is a dictionary of letter pairs for encoding.
encod = Dict()
Line 1,149:
canontxt = canonical(txt)
letterpairs = map(x -> canontxt[x], findall(r"(.)(?:(?!\1)(.))?", canontxt))
 
if isencode
# Encode text
4,105

edits