Skip to content

Instantly share code, notes, and snippets.

@minhajuddin
Created May 17, 2016 18:58
Show Gist options
  • Select an option

  • Save minhajuddin/8036d96b271bf16c9aea2e55a125dce5 to your computer and use it in GitHub Desktop.

Select an option

Save minhajuddin/8036d96b271bf16c9aea2e55a125dce5 to your computer and use it in GitHub Desktop.
Mcrypt using CFB
defmodule Mcrypttest do
@algo :rijndael_256
@mode :cfb
@key "00000000000000000000000000000000"
@iv "00000000000000000000000000000000"
def encrypt(plaintext) do
Mcrypt.encrypt(plaintext, @algo, @mode, @key, @iv)
end
def decrypt(ciphertext) do
Mcrypt.decrypt(ciphertext, @algo, @mode, @key, @iv)
end
end
{:ok, bin} = Mcrypttest.encrypt "mujju"
# => {:ok, <<50, 161, 213, 87, 56>>}
Mcrypttest.decrypt bin
# => {:ok, "mujju"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment