I am trying to sign a string with an RSA key in Python. I have working JavaScript code that does it, but now I need to replicate it in Python using Python-RSA.
In particular, these are the two JavaScript calls that I need to deal with:
const key = await crypto.subtle.importKey(
'raw',
bytesOfSecretKey,
{ name: 'HMAC', hash: 'SHA-256' },
false,
['sign']);
and
const mac = await crypto.subtle.sign('HMAC', key, bytesOfStringToSign));
where bytesOfSecretKey is just a key string represented as bytes, and bytesOfStringToSign is the string I am signing. Any pointers would be appreciated!
hmac). Python-RSA is not required for this (and afaik does not even provide this functionality).signature = hmac.new(key.encode("utf-8"), str.encode("utf-8"), hashlib.sha256).hexdigest()