I am unable to sign a string using my private key with the following conditions:
- Use SHA 256 algorithm to calculate the hash of the string
- Use the private key and RSA (PKCS1_PADDING) algorithm to sign the Hash Value
- Base64 encode the encrypted Hash Value
The code I am using is below, yet the signature does not match on the server side.
from Crypto.Signature import PKCS1_v1_5 from Crypto.Hash import SHA256 from Crypto.PublicKey import RSA import base64 pkey = RSA.importKey(keystring) message = "Hello world" h = SHA256.new(message.encode()) signature = PKCS1_v1_5.new(pkey).sign(h) result = base64.b64encode(signature).decode()
Can anyone help me troubleshoot why my signature is not matching?