Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decrypting a phoney value breaks when testing #3

Closed
suprafly opened this issue Apr 22, 2016 · 2 comments
Closed

Decrypting a phoney value breaks when testing #3

suprafly opened this issue Apr 22, 2016 · 2 comments

Comments

@suprafly
Copy link

suprafly commented Apr 22, 2016

A simple test:

    test "decrypt something phoney" do
      {resp, _} = Cipher.decrypt("nonsense")    
      assert resp == :error
    end

Returns this error:

    ** (ArgumentError) argument error
         stacktrace:
           (crypto) :crypto.aes_cbc_crypt("f501bc2316ae38b1", "33G<I0WWJiEn1{;Y", <<158, 137, 236, 122, 123, 30>>, false)
       lib/cipher.ex:39: Cipher.decrypt/1

I suspect that during testing, the helper functions to retrieve the :keyphrase and :ivphrase are not working correctly: https://github.com/rubencaro/cipher/blob/master/lib/cipher/helpers.ex

You can see this by extracting the definition and trying it in a test. When I add this line to my test:
IO.inspect Application.get_env(Mix.Project.get!.project[:app], :keyphrase, nil)
...the outut is: nil

@rubencaro
Copy link
Owner

That's something else I think. See:

iex(1)> Cipher.decrypt("random")
{:error, "Could not decode crypted string 'random'"}
iex(2)> Cipher.decrypt("nonsense")
** (ArgumentError) argument error
    (crypto) :crypto.aes_cbc_crypt("1c538c5bcef14695", "testieivphrasefo", <<158, 137, 236, 122, 123, 30>>, false)
    (cipher) lib/cipher.ex:39: Cipher.decrypt/1

I'm on it now.

@rubencaro
Copy link
Owner

Just released 1.0.2 including this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants