26 lines
670 B
Plaintext
26 lines
670 B
Plaintext
rem Return the ROT13 transformation of s$, preserving case \
|
|
and passing non-alphabetic characters without change
|
|
|
|
def fn.rot13$(s$)
|
|
normal$ ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
|
rotated$="NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm"
|
|
outstr$ = ""
|
|
for i% = 1 to len(s$)
|
|
c$ = mid$(s$,i%,1)
|
|
k% = match(c$,normal$,1)
|
|
if k% <> 0 then c$ = mid$(rotated$,k%,1)
|
|
outstr$ = outstr$ + c$
|
|
next i%
|
|
fn.rot13$ = outstr$
|
|
return
|
|
fend
|
|
|
|
plain$ = "The quick brown fox jumps over the lazy dog."
|
|
encoded$ = fn.rot13$(plain$)
|
|
|
|
print "Plain Text: "; plain$
|
|
print "Encoded : "; encoded$
|
|
print "Restored : "; fn.rot13$(encoded$)
|
|
|
|
end
|