RosettaCodeData/Task/Substitution-cipher/Picat/substitution-cipher-2.picat
2023-07-01 13:44:08 -04:00

23 lines
554 B
Text

main =>
S = "The quick brown fox jumped over the lazy dog!!!",
E = encrypt(S),
println(E),
D = decrypt(E),
println(D),
D == S,
println(ok),
nl.
encrypt(L) = [EncryptMap.get(C,C) : C in L] =>
base(Base),
subs(Subs),
EncryptMap = new_map([B=S : {B,S} in zip(Base,Subs)]).
decrypt(L) = [DecryptMap.get(C,C) : C in L] =>
base(Base),
subs(Subs),
DecryptMap = new_map([S=B : {B,S} in zip(Base,Subs)]).
base("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ").
subs("VsciBjedgrzyHalvXZKtUPumGfIwJxqOCFRApnDhQWob LkESYMTN").