Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,25 @@
shared void run() {
function normalize(String text) => text.uppercased.filter(Character.letter);
function crypt(String text, String key, Character(Character, Character) transform) => String {
for ([a, b] in zipPairs(normalize(text), normalize(key).cycled))
transform(a, b)
};
function encrypt(String clearText, String key) =>
crypt(clearText, key, (Character a, Character b) =>
('A'.integer + ((a.integer + b.integer - 130) % 26)).character);
function decrypt(String cipherText, String key) =>
crypt(cipherText, key, (Character a, Character b) =>
('A'.integer + ((a.integer - b.integer + 26) % 26)).character);
value key = "VIGENERECIPHER";
value message = "Beware the Jabberwock, my son! The jaws that bite, the claws that catch!";
value encrypted = encrypt(message, key);
value decrypted = decrypt(encrypted, key);
print(encrypted);
print(decrypted);
}