1

I'm trying to create a signature in node using this code:

var crypto = require('crypto');

var data = 'some data'
var signer = crypto.createSign('RSA-SHA256');
signer.write(data, 'base64');
signer.end();
var signature = signer.sign(privateKey, 'base64');

The signature and data are sent to python server.

Now I'm want to verify it using python code:

from base64 import b64decode, b64encode  
from Crypto.Hash import SHA256
from Crypto.PublicKey import RSA
from Crypto.Signature import PKCS1_v1_5

rsakey = RSA.importKey(public_key)
signer = PKCS1_v1_5.new(rsakey)                     
digest = SHA256.new()                               
digest.update(data)                      
signer.verify(digest, b64decode(signature))

The verification fails. When I use the same language for both sign and verify it works. Any thoughts?

1 Answer 1

1

I had the same problem, and have found this to work:

import rsa
rsa.verify(message, signature, public_key)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.