【发布时间】:2012-09-22 21:17:52
【问题描述】:
我想使用 nodeJS 对文件进行签名。我得到了一个 p12 证书(包括私钥)、一个密码和一个 pem 证书。
这里显示了它是如何在 ruby 中完成的: https://gist.github.com/de4b602a213b4b264706
提前致谢!
【问题讨论】:
标签: node.js cryptography
我想使用 nodeJS 对文件进行签名。我得到了一个 p12 证书(包括私钥)、一个密码和一个 pem 证书。
这里显示了它是如何在 ruby 中完成的: https://gist.github.com/de4b602a213b4b264706
提前致谢!
【问题讨论】:
标签: node.js cryptography
您应该能够在crypto 模块(参见http://nodejs.org/docs/v0.4.2/api/all.html#crypto)中使用createSign 来做您想做的事。代码最终看起来像这样(来自http://chimera.labs.oreilly.com/books/1234000001808/ch05.html#chap7_id35952189):
var crypto = require('crypto');
var fs = require('fs');
var pem = fs.readFileSync('key.pem');
var key = pem.toString('ascii');
var sign = crypto.createSign('RSA-SHA256');
sign.update('abcdef'); // data from your file would go here
var sig = sign.sign(key, 'hex');
【讨论】: