[erlang-questions] aes-128-cbc decryption in erlang

Maxim Treskin <>
Sat Feb 20 18:33:58 CET 2010


Hello

I wrote function which encodes/decodes arbitrary text using specified
Key and IVec:


aes_dec() ->
    Key = <<"ABCDEFGHIJKLMNOPQRSTUVWXYZ123456">>,
    IVec = <<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0>>,
    Text = <<"gdfgertehgrfcnyeyuyrfghhhhhdtest">>,
    Enc = crypto:aes_cbc_128_encrypt(Key, IVec, Text),
    Res = crypto:aes_cbc_128_decrypt(Key, IVec, Enc),
    io:format("Res: ~s~n", [binary_to_list(Res)]).


Result of function is:

1> cr_util:aes_dec().
ïQRSTUVWXYZ123456gdfgertehgrfcnyeyuyrfghhhhhdtest
ok

It is really unexpected for me. Can you help me?

Thank you

On 20 February 2010 05:39, Vance Shipley <> wrote:
> Maxim,
>
> For an example of it's use you could look at the milenage
> module from the 3Gdb HSS project:
>
>        http://www.3gdb.org/doc/
>   http://code.google.com/p/hss/source/browse/trunk/src/milenage.erl
>
> --
>        -Vance
>
> On Fri, Feb 19, 2010 at 10:23:00PM +0600, Maxim Treskin wrote:
> }  There is function aes_cbc_128_decrypt which takes Key, IVec and
> }  encoded data, but how I can get an IVec?
>



-- 
Maxim Treskin


More information about the erlang-questions mailing list