ntrepid8 / ex_crypto

Wrapper around the Erlang crypto module for Elixir.
MIT License
150 stars 48 forks source link

Key Strength #38

Closed cgorshing closed 4 years ago

cgorshing commented 4 years ago

The documentation shows

{:ok, aes_256_key} = ExCrypto.generate_aes_key(:aes_256, :base64)
{:ok,
 "Bs_BzhuwseEA8ZUvuEY0mq9Rmlv6cSoU_RaYD14Q62HiN_kJ4FiaW0YYppf1ffYPQ56xuitxQtYAnaeP-Q5l1WPh5aExdwCG_PUm5g-MlOUA1XSSP2RvuQqAiHzazIzjGVSIcl0Gr7TSLPOoIQrPshMNaA4j3SGZ3lAOqO1quvXtDn-9Sxwr5dwV7VzOIvXRwb0GbZeYp8lnVJgeqHl8cEhUTfT_h9Pm7tU2CFeHZCDK8ntFT_t4q6VlcBcvw_Pj3CGcVSmpmCHMKW1brt6jXGBijqSTdbjYDZnCx2Q44VoYqMMZ1U2GnVyjc-ZuwugwGGqQ7UEqV_TOMjbK6Oxx-Q=="}

But when I ran this locally, I get these much shorter results:

iex(1)> ExCrypto.generate_aes_key(:aes_256, :base64)
{:ok, "7MCZHilcDU7C3JTIicel0HTbMdoewepNLbjf0Is5fpI="}
iex(2)> ExCrypto.generate_aes_key(:aes_256, :base64)
{:ok, "8rPe6WBHKsWzRB1bTlwVyaMqNWmo1X9kO33l36Twc1I="}
iex(3)> ExCrypto.generate_aes_key(:aes_256, :base64)
{:ok, "n4LPbbqZ2Zopp7XKM7WBlq-1CwHRU96ljkAm3y8S-tQ="}
iex(4)> ExCrypto.generate_aes_key(:aes_256, :base64)
{:ok, "nNa1fpWJ7lqtXHbQ3dMLl5Fg8dyaJTdrPKl2iHaIzTg="}
iex(5)> ExCrypto.generate_aes_key(:aes_256, :base64)
{:ok, "FyoaY2gPzaz-3DEHdqtoArdp2lf203B0tuf5grYY_9w="}

The versions I have on my Mac 10.15.3 is:

$ elixir --version
Erlang/OTP 22 [erts-10.6.4] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]

Elixir 1.9.4 (compiled with Erlang/OTP 20)

$ openssl version
LibreSSL 2.8.3

What am I missing that these keys seem shorter than they should be.