Anonymous user
Playfair cipher: Difference between revisions
→{{header|REXX}}: extended the REXX pgm to allow a multi-word cipher (which necessitated changing the order of the 1st two variables). -- ~~~~
(→{{header|REXX}}: added a thank you in the REXX section header, added a literal to make a couple of error messages easier to peruse (in the program). -- ~~~~) |
(→{{header|REXX}}: extended the REXX pgm to allow a multi-word cipher (which necessitated changing the order of the 1st two variables). -- ~~~~) |
||
Line 363:
<br>For ease of viewing and comparing, the output is in capitalized digraphs (which are really ''digrams'') as well as the original input(s).
<br>Thanks to Walter Pachl, this program is now sensitive of using a suitable ''double character'' when '''X''' is present in the cipher key.
<br>Also, more thanks are due to Walter Pachl
<br>
<br>(this is the ''possible text'' part of the REXX code).
<lang rexx>/*REXX program implements a PLAYFAIR cipher (encryption & decryption).*/
@abc='abcdefghijklmnopqrstuvwxyz'; @abcU=@abc /*lower and upper ABC's.*/
parse arg
if key =='' | key ==',' then do; key='Playfair example.'; oldK=key " ◄───using the default."; end
if omit=='' | omit==',' then omit='J' /*the "omitted" character. */
Line 373 ⟶ 374:
newKey =scrub(key , 1) /*scrub old cipher key──► newKey */
newText=scrub(text ) /* " " text ──► newText*/
if newText=='' then call err 'TEXT is empty or has no letters'
if length(omit)\==1 then call err 'OMIT letter must be only one letter'
Line 470:
════════════════Playfair encryption──► decryption──► encryption worked.
</pre>
'''output''' when using the input of: <tt>
<pre>
old cipher key: stuvw
|