Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const id = '__JUNK__';
- // Public key need to be in PKCS8 format
- // ssh-keygen -e -m PKCS8 -f id_rsa.pub > id_rsa.pkcs8
- const publicKey = fs.readFileSync(path.join(__dirname, 'id_rsa.pkcs8'), { encoding : 'utf8' });
- const privateKey = fs.readFileSync(path.join(__dirname, 'id_rsa'), { encoding : 'utf8' });
- // Sign
- const signer = crypto.createSign('RSA-SHA512');
- signer.update(id);
- const signature = signer.sign(privateKey, 'hex');
- // ...
- // Verify
- const verifier = crypto.createVerify('RSA-SHA512');
- verifier.update(ruid);
- const publicKeyBuf = new Buffer(publicKey, 'utf-8');
- const signatureBuf = new Buffer(signature, 'hex');
- const result = verifier.verify(publicKeyBuf, signatureBuf);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement