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 &nbsp; '''X''' &nbsp; is present in the cipher key.
<br>Also, more thanks are due to Walter Pachl firfor finding that the cipher key can't contain the OMIT character.
<br>Also added a aA fair amount of code was added to massage the decrypted encryption to remove doubled &nbsp; '''X'''es &nbsp; so as to match the original text.
<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 key omit _ .key '(' text /*TEXT is the phrase to be used. */ ;oldK=key /*save old.*/
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 _\=='' then call err 'too many arguments specified.'
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: &nbsp; <tt> stuvw x stuvw (myteest </tt>
<pre>
old cipher key: stuvw