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>