xml-crypto - XML 数据签名和加密


未知
跨平台
JavaScript

软件简介

xml-crypto 是一个 Node.js 的扩展用来实现对 XML
数据签名和加密。

示例代码:

    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())