Rot-13: Difference between revisions
Content added Content deleted
imported>KayproKid (→{{header|S-BASIC}}: added additional approach) |
imported>KayproKid m (→{{header|An alternate approach}}: Code cleanup of 3rd S-BASIC approach) |
||
Line 5,638: | Line 5,638: | ||
</pre> |
</pre> |
||
Still a third approach makes use of S-BASIC's awkward (and |
Still a third approach makes use of S-BASIC's awkward (and poorly documented) XLATE function, which transforms each character in the input string by using its ASCII value as an index into the translation string. |
||
<syntaxhighlight lang = "basic"> |
<syntaxhighlight lang = "basic"> |
||
function rot13(s = string) = string |
|||
var tr = string:127 |
|||
rem - set up translation table |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
rem - |
rem - test the function |
||
⚫ | |||
⚫ | |||
⚫ | |||
var plain, encrypted = string |
|||
⚫ | |||
print "Plain text: "; s |
|||
⚫ | |||
⚫ | |||
print " |
print "Plain text: "; plain |
||
encrypted = rot13(plain) |
|||
print " |
print "Encrypted : "; encrypted |
||
print "Restored : "; rot13(encrypted) |
|||
end |
end |