I am trying to encrypt a message using PGP but I am getting an error that states:
ReferenceError: TextDecoder is not defined
at Object.decodeUTF8 (node_modules/openpgp/src/util.js:225:21)
at Do.read (node_modules/openpgp/src/packet/userid.js:78:25)
at callback (node_modules/openpgp/src/packet/packetlist.js:82:28)
at Xs (node_modules/openpgp/src/packet/packet.js:282:13)
at node_modules/openpgp/src/packet/packetlist.js:96:11
This is how my code looks like:
const plainData = random.uuid()
const publicKeyArmored = fs.readFileSync('/path/any.asc').toString();
const publicKey = await openpgp.readKey( { armoredKey: publicKeyArmored } )
console.log(publicKey)
When I print the publicKeyArmored, all is OK. As soon as it reaches the console.log shown before, the error appears
This is how I ended up making this work, I hope it helps someone: