iam using cryptojs on react app to encvrypt a card that i send over the wire to my node app where i decrypt it using the same key. iam pretty sure it was working before but iam not sure. Iam getting an empty string on decryption and i cant figure out what i am doing wrong
in react app
handleEncrypt =(ccNumber)=>{
const key = process.env.REACT_APP_SITE_ENCRYPTION_KEY
const encrypted = window.CryptoJS.AES.encrypt(ccNumber,key.trim()).toString()
return encrypted;
}
in config
REACT_APP_SITE_ENCRYPTION_KEY = y$3&g</l1=OrNunxw5{g72lmkX+:<sL^
on the node side
const CryptoJS = require('crypto-js');
function decryptor(encryptedCreditCard) {
const decryptionKey = process.env.DECRYPTION_KEY;
const decryptedBytes = CryptoJS.AES.decrypt(
encryptedCreditCard,
decryptionKey,
);
const decryptedCreditCard = decryptedBytes.toString(CryptoJS.enc.Utf8);
return decryptedCreditCard;
}
any help will be much appreciated