2 February 2016

Generating hmac involves using "private" key. So you you need to "double encode it". In python you can achieve it using two libraries hashlib and hmac.

Source code viewer
  1. import hashlib
  2. import hmac
  3.  
  4. key = '8oe0i89o7es243t5s234'
  5. message = 'Body text for the hash.';
  6.  
  7. # Generate the hash.
  8. signature = hmac.new(
  9. key,
  10. message,
  11. hashlib.sha256
  12. ).hexdigest()
Programming Language: Python