0

I want to encrypt and decrypt my xml file.
I read w3c recommendation about this process.
by some searching I found npm xml-encryption 1.2.0
https://www.npmjs.com/package/xml-encryption
Has anyone tried it before?
I've installed it but it shows me that error
"require is not defined"
Have you guys any other ways to encrypt xml?

my code

<html>
  <head>
<script>
var xmlenc = require('xml-encryption');
var options = {
  rsa_pub: fs.readFileSync('./public.pem'),
  pem: fs.readFileSync('./public.pem'),
  encryptionAlgorithm: 'http://www.w3.org/2001/04/xmlenc#aes256-cbc',
  keyEncryptionAlgorithm: 'http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p',
  disallowEncryptionWithInsecureAlgorithm: true,
  warnInsecureAlgorithm: true
};

xmlenc.encrypt('content to encrypt', options, function(err, result) {
    console.log(result);
})
</script>
</head>
<body>
</body>
</html>
HUS.97
  • 7
  • 1
  • 5
  • 1
    XML is just text, you can encrypt it any way you want. – Barmar Jun 08 '20 at 22:10
  • I know that but,I have to use XML Encryption _the whole xml document_ depending on w3c recommendation,do you have any suggestions? – HUS.97 Jun 09 '20 at 16:57

1 Answers1

0

I found the solution here
Client on node: Uncaught ReferenceError: require is not defined
firstly I thought this error is related to the package xml-encryption because I already have installed nodejs

HUS.97
  • 7
  • 1
  • 5