crypto:sha_mac correct invcation

Paolo Negri paolo.negri@REDACTED
Thu Dec 2 11:52:14 CET 2010


Hi everyone

Sorry for the newbie question, I'm trying to understand how
crypto:sha_mac/2 should be invoked

Key = "my_key".
Data = "GET\n\n\nThu, 02 Dec 2010 10:05:01 GMT\n/".

crypto:sha_mac(Key, Data).
** exception error: bad argument
     in function  port_control/3
        called as port_control(crypto_drv02,11,
                               [<<0,0,0,6>>,
                                "my_key","GET\n\n\nThu, 02 Dec 2010
10:05:01 GMT\n/"])

This is an extraction from a library I'm trying to use
https://github.com/Voker57/s3erl

and it breaks because internally it executes such a call to crypto:sha_mac

I've tried on Erlang R13B03 (erts-5.7.4) installed with apt-get on
ubuntu 10.04 and on Erlang R13B04 (erts-5.7.5) compiled from source
always on ubuntu 10.04

I read http://www.erlang.org/doc/man/crypto.html#sha_mac-2 and tried
converting the list to binary but I didn't manage to make it work.

crypto:sha_mac(list_to_binary("my_key"),list_to_binary("GET\n\n\nThu,
02 Dec 2010 10:05:01 GMT\n/")).
** exception error: bad argument
     in function  port_control/3
        called as port_control(crypto_drv02,11,
                               [<<0,0,0,6>>,
                                <<"my_key">>,
                                <<"GET\n\n\nThu, 02 Dec 2010 10:05:01
GMT\n/">>])

Thanks for your help.

Paolo


More information about the erlang-questions mailing list