适用于Node.js的XML数字签名和安全加密包:xml-crypto

openkk 8年前

适用于Node.js的XML数字签名和安全加密包,采用纯JavaScript开发。

示例代码:

    var SignedXml = require('xml-crypto').SignedXml        , FileKeyInfo = require('xml-crypto').FileKeyInfo          , fs = require('fs')        var xml = "<library>" +                  "<book>" +                    "<name>Harry Potter</name>" +                  "</book>"                "</library>"        var sig = new SignedXml()      sig.addReference("//*[local-name(.)='book']")          sig.signingKey = fs.readFileSync("client.pem")      sig.computeSignature(xml)      fs.writeFileSync("signed.xml", sig.getSignedXml())

项目主页:http://www.open-open.com/lib/view/home/1346079116098