cryptol/examples/xor_cipher.cry
2017-07-13 10:55:44 -07:00

7 lines
264 B
Plaintext

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