Created
September 16, 2010 16:38
-
-
Save omarkj/582723 to your computer and use it in GitHub Desktop.
This file contains 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 fs = require('fs'), | |
assert = require('assert'), | |
crypto = require('crypto'); | |
var msg = "Gaur!"; | |
fs.readFile('PrivateKey.pem', 'utf-8', function(e,pri) { | |
var signer = crypto.createSign('sha256').update(msg); | |
var signature = signer.sign(pri, output_format='base64'); | |
fs.readFile('PublicKey.pem', 'utf-8', function(e,pub) { | |
var verifier = crypto.createVerify('sha256').update(msg); | |
var verified = verifier.verify(pub, signature, signature_format='base64'); | |
assert.equal(verified, 1) | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment