node package manager


<a href=""><img src="" /></a>

W3C XML Encryption implementation for node.js (

npm install xml-encryption
var xmlenc = require('xmlenc');
var options = {
  rsa_pub: fs.readFileSync(__dirname + '/'),
  pem: fs.readFileSync(__dirname + '/your_public_cert.pem'),
  encryptionAlgorithm: '',
  keyEncryptionAlgorighm: ''
xmlenc.encrypt('content to encrypt', options, function(errresult) {


<xenc:EncryptedData Type="" xmlns:xenc="">
  <xenc:EncryptionMethod Algorithm="" />
    <KeyInfo xmlns="">
      <e:EncryptedKey xmlns:e="">
        <e:EncryptionMethod Algorithm="">
          <DigestMethod Algorithm="" />
          <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(errresult) {
// result 
decrypted content

Currently the library supports:

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

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.