react-native-crypto-js
react-native-crypto-js copied to clipboard
Decryption using CryptoJS.AES.decrypt results empty String
var scanIO = "encrpytedstring";
above scanIO variable is generated from web Crypto JS library and below i'm decrypting in React-native
let scannedGuid = CryptoJS.enc.Utf8.stringify(CryptoJS.AES.decrypt(scanIO, 'seckey'))
above code Returns empty string, but when i try same thing on Web version CryptoJS libraries using Web tools it gives me required output. Could you help is it because the conflict of Web and react-native version ?
React native version : 0.59.1
@nikitpanchal Thank you for reporting issues, can you please share a sample code? I will check and fix it as soon as possible.
same here.
in simulator it's working but when I deploy a debug .apk returns empty string
const bytes = CryptoJS.AES.decrypt(data, secret);
const originalText = bytes.toString(CryptoJS.enc.Utf8);
return originalText
also React native version: 0.59.1
The same for RN 0.61.4
Hi is there any solution to this yet?
I have confirmed with RN 0.61.4, the AES decrypt will work fine while the scheme of the app is in develop, but upon making a proper release build it will return an empty string.
I could not find a solution, I am not using the NodeJS CryptoJs library for this.
@Metroxe Could you please send me more information or put your sample code here that I check?
same here
I try use this lib between two differents devices, but decrypt returns empty string if I try decrypt before make a encrypt.
In my case, one device encrypt the password and send for the server.. when I try do login in another device.. the decrypt returns empty key.
decrypt not working in APK (android) return empty string
let str = "mystring";
let bytes = CryptoJS.AES.decrypt(str, CONST.SHARE_KEY);
let originalText = bytes.toString(CryptoJS.enc.Utf8);
console.log("originalText 2", ''"); <------ output
react-native : 0.61
use "crypto-js": "3.3.0", not react native CryptoJS only v 3.3.0 will work in APK add "crypto-js": "3.3.0" in your package.json
Same problem here.
I changed to "crypto-js": "3.1.9-1" and works fine.
I am facing the same issue that in debug mode everything works fine but in release mode of android it returns empty string.
export const decryptEncryptedKeyFromServer = async (encryptedKey) => {
let bytes = await CryptoJS.AES.decrypt(encryptedKey, Config?.SECRET_KEY);
let decryptedKey = await bytes.toString(CryptoJS.enc.Utf8);
return decryptedKey;
}
where encryptedKey
is from server and Config?.SECRET_KEY
is secret used for encryption
is yet?
I have confirmed with RN 0.61.4, the AES decrypt will work fine while the scheme of the app is in develop, but upon making a proper release build it will return an empty string.
Fixed? Any solutions?
Same problem here.
I changed to "crypto-js": "3.1.9-1" and works fine.
Thanks it works
anyone figured out this one . its returning a null. heres the code for decrypting ..
router.decryptData = function (ciphertext) {
const bytes = CryptoJS.AES.decrypt(ciphertext, config.ENCRYPTION_SALT);
try { return JSON.parse(bytes.toString(CryptoJS.enc.Utf8)) }
catch (err) { return null }
}
any other solutions than installing the previous version of this package?
same here
I try use this lib between two differents devices, but decrypt returns empty string if I try decrypt before make a encrypt.
In my case, one device encrypt the password and send for the server.. when I try do login in another device.. the decrypt returns empty key.
Yeah me too. One microservice was encrypting and then delegating the decryption to other downstream services. but it wouldn't work if the encryption was done on different machine. it works however if am using the same machine. the weird part is that using docker doesn't seem to have any impact.
Has this been resolved? I am having the same issue with CryptoJS 4.1.1. Encrypting on one machine/app and decrypting on another returns an empty string upon decryption.
anyone ever find a solution for this? Im on 4.1.1.
@blustreeky23 for my case I was passing values as encrypted from the process.env.secrety_key
and for some reason that value was null prior to being passed to the encrypt()
method. Not a solid solution but worth double checking that the value being encrypted isn't an empty string| null to begin with.