RosettaCodeData/Task/Rot-13/BASIC256/rot-13.basic

34 lines
748 B
Plaintext

# rot13 Cipher v2.0
# basic256 1.1.4.0
# 2101031238
dec$ = ""
type$ = "cleartext "
ctext$ = ""
sp = 0
iOffset = 13 #offset assumed to be 13 - uncomment line 11 to change
input "For decrypt enter " + "<d> " + " -- else press enter > ",dec$
# input "Enter offset > ", iOffset
if dec$ = "d" OR dec$ = "D" then
iOffset = 26 - iOffset
type$ = "ciphertext "
end if
input "Enter " + type$ + "> ", str$
str$ = upper(str$)
for i = 1 to length(str$)
iTemp = asc(mid(str$,i,1))
if iTemp > 64 AND iTemp < 91 then
iTemp = ((iTemp - 65) + iOffset) % 26
print chr(iTemp + 65);
sp = sp + 1
if sp = 5 then
print(' ');
sp = 0
endif
endif
next i