cryptol/examples/xor_cipher.cry

7 lines
264 B
Plaintext
Raw Normal View History

2017-07-13 20:55:44 +03:00
encrypt : {a}(fin a) => [8] -> [a][8] -> [a][8]
encrypt key plaintext = [pt ^ key | pt <- plaintext ]
decrypt : {a}(fin a) => [8] -> [a][8] -> [a][8]
decrypt key ciphertext = [ct ^ key | ct <- ciphertext ]
property roundtrip k ip = decrypt k (encrypt k ip) == ip