React native in production: Cryptojs AES Error: Malformed UTF-8 data

Viewed 618

I used same code for aes encrypt (in https://github.com/imchintan/react-native-crypto-js#readme) for my react-native android app and nodejs server,

let data = [{id: 1}, {id: 2}]
// Encrypt in react-native android app
let ciphertext = CryptoJS.AES.encrypt(JSON.stringify(data), 'secret key 123').toString();

// Decrypt in the nodejs server
let bytes = CryptoJS.AES.decrypt(ciphertext, 'secret key 123');
let decryptedData = JSON.parse(bytes.toString(CryptoJS.enc.Utf8));

when my react-native app is in "JS Dev Mode" activated and "JS Minify" desactivated the decryption in the server works fine, but when i configure my app as "JS Dev Mode" desactivated and "JS Minify" activated i cant decrypt the data in the server,

Error: Malformed UTF-8 data at Object.stringify

the error throw in the server only when the app is in production mode, the error happend exactly when execute: bytes.toString(CryptoJS.enc.Utf8)

Can someone explain to me what I am doing wrong or how to solve the problem?

0 Answers
Related