Skip to content

Instantly share code, notes, and snippets.

@yaronn
Created May 20, 2012 16:43
Show Gist options
  • Save yaronn/2758727 to your computer and use it in GitHub Desktop.
Save yaronn/2758727 to your computer and use it in GitHub Desktop.
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())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment