TypeError in HMAC module.

Prabir Kr Sarkar prabir.kr.sarkar at gmail.com
Mon Mar 24 16:15:08 CET 2014

   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'),

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

*Thanks and Regards*
*Prabir Sarkar*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20140324/d6868c21/attachment.html>

More information about the Python-list mailing list