OiO.lk Blog python python rsa sign result in different library?
python

python rsa sign result in different library?


My goal is to have the signature results consistent with the server’s results. I’ve heard that signatures may involve randomness, which leads to different results each time, but in practice, when I used the cryptography library:

signature = privateKey.sign(data, padding.PKCS1v15(), hashes.SHA256())

the results were consistent each time and matched the server’s results. I want to simplify the imports and only use Crypto or cryptodome. When using cryptodome with the following code:

dataHash = SHA256.new(data)
signature = PKCS1_v1_5.new(privateKey).sign(dataHash)

the results vary each time, likely due to the salt.

I want to ask is it possible to do what cryptography does in Crypto or cryptodome that can generate the same signature every time. Thank you!



You need to sign in to view this answers

Exit mobile version