RosettaCodeData/Task/Caesar-cipher/11l/caesar-cipher.11l

21 lines
590 B
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

F caesar(string, =key, decode = 0B)
I decode
key = 26 - key
V r = * string.len
L(c) string
r[L.index] = S c
a..z
Char(code' (c.code - a.code + key) % 26 + a.code)
A..Z
Char(code' (c.code - A.code + key) % 26 + A.code)
E
c
R r
V msg = The quick brown fox jumped over the lazy dogs
print(msg)
V enc = caesar(msg, 11)
print(enc)
print(caesar(enc, 11, decode' 1B))