Python Forum
python hmac gave different result than php hash_hmac
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
python hmac gave different result than php hash_hmac
#2
you have switched the place of key and msg positional arguments for python example.

>>> import hashlib
>>> import hmac
>>> hmac.new(b'skey', b'abc', hashlib.sha256).hexdigest()
'ee6177854ca54cfcc49f1bf44256eefc0f9f3fb197c9af9ddf821fa4282b5906'
>>> hmac.new(key=b'skey', msg=b'abc', digestmod=hashlib.sha256).hexdigest()
'ee6177854ca54cfcc49f1bf44256eefc0f9f3fb197c9af9ddf821fa4282b5906'
>>>
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
RE: python hmac gave different result than php hash_hmac - by buran - Feb-18-2019, 02:08 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Palindrome in Python - result always false RavCOder 13 9,799 Oct-16-2019, 01:38 PM
Last Post: perfringo
  Post JSON from python to PHP don't give expected result pgagnebin 1 4,734 Sep-04-2019, 10:29 PM
Last Post: micseydel
  python result problem of an iteration algorithm for power allocation Jessica 1 3,372 Sep-07-2018, 08:08 PM
Last Post: micseydel
  python code (embedded in Redshift) to return result of the query Mel 0 2,887 Aug-24-2018, 06:12 PM
Last Post: Mel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020