Skip to content

Instantly share code, notes, and snippets.

@sellout
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sellout/11390058 to your computer and use it in GitHub Desktop.
Save sellout/11390058 to your computer and use it in GitHub Desktop.
confoundMessage : (StreamCipher k, Serializable i, Serializable o) =>
k -> i -> o
confoundMessage key message =
let encodedMsg = encode message
in decode (zipWith xor
(Prelude.Stream.take (length encodedMsg)
(generateKeystream key))
encodedMsg)
-- When elaborating an application of function Prelude.Vect.zipWith:
-- Unifying n and length (encode message) would lead to infinite value
------------------
-- second attempt:
confoundMsg : StreamCipher k => k -> Vect m (Bits n) -> Vect m (Bits n)
confoundMsg {m=m} key = zipWith xor (take m (generateKeystream key))
confoundMessage : (StreamCipher k, Serializable i, Serializable o) =>
k -> i -> o
confoundMessage key message = decode (confoundMsg key (encode message))
-- ./Data/Crypto/Encryption/StreamCipher.idr:27:17:Incomplete term decode (confoundMsg key (encode message))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment