Created
October 3, 2012 11:32
-
-
Save heapwolf/3826497 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 crypto = require('crypto'); | |
var path = require('path'); | |
var fs = require('fs'); | |
var key = fs.readFileSync(path.join(process.env['HOME'], '.ssh/foo_rsa')).toString(); | |
var pubkey = fs.readFileSync(path.join(process.env['HOME'], '.ssh/foo_rsa.pub')).toString(); | |
var data = "abcdef" | |
var sign = crypto.createSign('RSA-SHA256'); | |
sign.update(data); | |
var Sig = sign.sign(key, 'hex'); | |
var verify = crypto.createVerify('RSA-SHA256'); | |
verify.update(data); | |
console.log(verify.verify(pubkey, Sig, 'hex')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Solution...