TypeError in HMAC module.

P

Prabir Kr Sarkar

Hi,
I am trying to create a hashed message for authentication for a REST API
call. I have got the key from a keyring as :-

key = keyring.get_password('AWS_keyring','username')

& calculating the signature as :-
signature = hmac(key, message.encode('UTF-8'),
hashlib.sha1).digest().encode('base64')[:-1]

But, while running the script I get the following errors :-

File "/usr/lib64/python2.6/hmac.py", line 133, in new
return HMAC(key, msg, digestmod)
File "/usr/lib64/python2.6/hmac.py", line 72, in __init__
* self.outer.update(key.translate(trans_5C))*
*TypeError: character mapping must return integer, None or unicode*

My python version is :-

# python -V
Python 2.6.9

Can someone please help me as to how I can resolve this issue. Thanks in
advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top