Created
March 8, 2014 16:02
-
-
Save mdobson/9434027 to your computer and use it in GitHub Desktop.
Public Key Verification
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var crypto = require('crypto'); | |
var path = require('path'); | |
var fs = require('fs'); | |
var sign = crypto.createSign('RSA-SHA256'); | |
var privateKey = path.join(__dirname, 'priv.pem'); | |
var publicKey = path.join(__dirname, 'pub.pem'); | |
var key = fs.readFileSync(privateKey); | |
var buf = sign.sign(key); | |
var verify = crypto.createVerify('RSA-SHA256'); | |
var pubKey = fs.readFileSync(publicKey); | |
console.log(verify.verify(pubKey, buf)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment