Jump to content

Playfair cipher: Difference between revisions

m
m (J: fix clipped code)
Line 246:
ref=:pairs
i.0 0
)
 
pairs=: 3 :0
2{."1 -.&' '"1 ~."1 (_2]\ norm y),"1 'XQV'
)
 
encrypt=:3 :0
,alt{~ref i. 2{."1 -.&' '"1 ~."1 (_2]\ normpairs y),"1 norm 'XQV'
)
 
decrypt=:3 :0
,ref{~alt i. 2{."1 -.&' '"1 ~."1 (_2]\ normpairs y),"1 norm '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:
6,962

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.