I need help finding out how I can decode a base64 encoded HMAC-SHA256 hash with python.
From an API I'm given a base64 encoded HMAC-SHA256 hash of a secret key.
The message I get from the API is: "Mw2aXjiDQABoNi5jB09ie8iTkET4t6JiQJSh+/jIceY="
My secret is: "testapp"
Using the answer from this post Calculating a SHA hash with a string + secret key in python
import hmac
import hashlib
import base64
dig = hmac.new(b'testapp', msg=b'Mw2aXjiDQABoNi5jB09ie8iTkET4t6JiQJSh+/jIceY=, digestmod=hashlib.sha256).digest()
base64.b64encode(dig).decode()
I get "WTEb7ZIAPb89b0NV8NnI9+0x5alkng1LZ7Ffz39bveE="
I expected a response equal to my message. What am I doing wrong here ?
Any help is appreciated. Best regards Kresten