[erlang-questions] Crypto AES data block size

Alexander Petrovsky askjuise@REDACTED
Fri Jun 20 13:00:23 CEST 2014


Hi!

I need to encrypt some data with ads_cbc_128, and I do like:

crypto:aes_cbc_128_encrypt(<<"B3E80545C3C9968096E85A7E0A4A5779">>,
<<"96E85A7E0A4A5779">>, <<"id=14&bid=00.004300&clickUrl=
http://duckduckgo.com
&pid=3101&source=100&search-id=42&search-date=00:00:00">>).
** exception error: bad argument
     in function  crypto:aes_cbc_crypt/4
        called as
crypto:aes_cbc_crypt(<<"B3E80545C3C9968096E85A7E0A4A5779">>,
                                       <<"96E85A7E0A4A5779">>,
                                       <<"id=14&bid=00.004300&clickUrl=
http://duckduckgo.com
&pid=3101&source=100&search-id=42&search-date=00:00:00">>,
                                       true)

seems like the size of data should be the equal the power on 2, and then I
do:

crypto:aes_cbc_128_encrypt(<<"B3E80545C3C9968096E85A7E0A4A5779">>,
<<"96E85A7E0A4A5779">>, <<"id=14&bid=00.004300&clickUrl=
http://duckduckgo.com&pid=3101&source=100&search-id=42&search-date=00:00:00",
0:24/unit:8>>).
<<87,187,244,217,66,251,202,118,238,90,226,245,209,213,
  158,166,203,46,8,30,113,122,172,204,163,50,193,34,243,
  ...>>

Is there any way, don't fill the binary by zeros? How properly I should do
this?


-- 
Петровский Александр / Alexander Petrovsky,

Skype: askjuise
Phone: +7 914 8 820 815
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140620/62d930eb/attachment.htm>


More information about the erlang-questions mailing list