Playfair cipher: Difference between revisions
Content added Content deleted
Line 1,121: | Line 1,121: | ||
# Translate key into an encoding 5x5 translation matrix. |
# Translate key into an encoding 5x5 translation matrix. |
||
keyletters = unique([c for c in canonical(key * "ABCDEFGHIJKLMNOPQRSTUVWXYZ")]) |
keyletters = unique([c for c in canonical(key * "ABCDEFGHIJKLMNOPQRSTUVWXYZ")]) |
||
m = Char.((reshape(UInt8.(keyletters[1:25]), 5, 5)')) |
m = Char.((reshape(UInt8.(keyletters[1:25]), 5, 5)')) |
||
# encod is a dictionary of letter pairs for encoding. |
# encod is a dictionary of letter pairs for encoding. |
||
encod = Dict() |
encod = Dict() |
||
# Map pairs in same row of matrix m. |
# Map pairs in same row of matrix m. |
||
for i in 1:5, j in 1:5, k in 1:5 |
for i in 1:5, j in 1:5, k in 1:5 |