Playfair cipher: Difference between revisions

m
(J)
Line 222:
 
=={{header|J}}==
 
Rather than implement two versions of the rules, one for encrypt, one for decrypt, let's just make a lookup table. To decrypt we can look up in the other direction.
 
Implementation:
Line 253 ⟶ 255:
,ref{~alt i. 2{."1 -.&' '"1 ~."1 (_2]\ norm y),"1 'XQV'
)</lang>
 
We could obviously factor out a routine to clean the text and form pairs to use for both encrypt and decrypt, but it works well enough like it is.
 
Example use:
Line 263 ⟶ 267:
decrypt 'BMODZBXDNABEKUDMUIXMKZZRYI'
HIDETHEGOLDINTHETREXSTUMPX</lang>
 
 
=={{header|NetRexx}}==
6,962

edits