[![Build Status](https://travis-ci.org/auth0/node-xml-encryption.png)](https://travis-ci.org/auth0/node-xml-encryption)
Last updated a year ago by tngan .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @authenio/xml-encryption 
SYNC missed versions from official npm registry.

Build Status

W3C XML Encryption implementation for node.js (http://www.w3.org/TR/xmlenc-core/)


npm install xml-encryption


var xmlenc = require('xmlenc');

var options = {
  rsa_pub: fs.readFileSync(__dirname + '/your_rsa.pub'),
  pem: fs.readFileSync(__dirname + '/your_public_cert.pem'),
  encryptionAlgorithm: 'http://www.w3.org/2001/04/xmlenc#aes256-cbc',
  keyEncryptionAlgorighm: 'http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p'

xmlenc.encrypt('content to encrypt', options, function(err, result) {


<xenc:EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#">
  <xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes-256-cbc" />
    <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
      <e:EncryptedKey xmlns:e="http://www.w3.org/2001/04/xmlenc#">
        <e:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p">
          <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
          <X509Data><X509Certificate>MIIEDzCCAveg... base64 cert... q3uaLvlAUo=</X509Certificate></X509Data>
          <e:CipherValue>sGH0hhzkjmLWYYY0gyQMampDM... encrypted symmetric key ...gewHMbtZafk1MHh9A==</e:CipherValue>
        <xenc:CipherValue>V3Vb1vDl055Lp92zvK..... encrypted content.... kNzP6xTu7/L9EMAeU</xenc:CipherValue>


var options = {
    key: fs.readFileSync(__dirname + '/your_private_key.key'),

xmlenc.decrypt('<xenc:EncryptedData ..... </xenc:EncryptedData>', options, function(err, result) {

// result

decrypted content

Supported algorithms

Currently the library supports:

However, you can fork and implement your own algorithm. The code supports adding more algorithms easily

Issue Reporting

If you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. The Responsible Disclosure Program details the procedure for disclosing security issues.




This project is licensed under the MIT license. See the LICENSE file for more info.

Current Tags

  • 0.11.3                                ...           latest (a year ago)

2 Versions

  • 0.11.3                                ...           a year ago
  • 0.11.2                                ...           a year ago
Maintainers (1)
Today 8
This Week 12
This Month 47
Last Day 1
Last Week 28
Last Month 25
Dependencies (5)
Dev Dependencies (2)

Copyright 2014 - 2016 © taobao.org |