mirror of
https://git.sr.ht/~crc_/retroforth
synced 2024-11-16 19:48:56 +01:00
848ba7303b
FossilOrigin-Name: b5feea667d30aac255d1cfca61fed355d438d2ce6021677f1e53af6302b15eee
20 lines
820 B
Text
20 lines
820 B
Text
ROT13 ("rotate by 13 places", sometimes hyphenated ROT-13) is a simple
|
|
letter substitution cipher that replaces a letter with the letter 13
|
|
letters after it in the alphabet. ROT13 is a special case of the Caesar
|
|
cipher, developed in ancient Rome.
|
|
|
|
Because there are 26 letters (21^3) in the basic Latin alphabet, ROT13
|
|
is its own inverse; that is, to undo ROT13, the same algorithm is
|
|
applied, so the same action can be used for encoding and decoding. The
|
|
algorithm provides virtually no cryptographic security, and is often
|
|
cited as a canonical example of weak encryption.
|
|
|
|
(Taken from https://en.m.wikipedia.org/wiki/ROT13)
|
|
|
|
This is an implementation of ROT13 in RETRO.
|
|
|
|
~~~
|
|
'nopqrstuvwxyzabcdefghijklm 'MAP s:const
|
|
:encode (c-c) $a - MAP + fetch ;
|
|
:rot13 (s-s) s:to-lower [ dup c:letter? [ encode ] if ] s:map ;
|
|
~~~
|