You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To convert an IV created from Crypto.randomBytes(16) to string & then convert it back to array buffer (which Crypto.createDecipheriv() can consume). Basically, we are sending IV in string format from the frontend & the backend will consume it to decipher data.
Problem
When we convert this IV to string & then convert it back to ArrayBuffer, they aren't equal/same. This is causing issues in decrypting the encrypted data.
importCryptofrom'react-native-quick-crypto';import{Buffer}from'@craftzdog/react-native-buffer';constIV=Crypto.randomBytes(IV_LENGTH_IN_BYTES);// convert IV to UTF-8 stringconststringIv=IV.toString();// Buffer.from(IV).toString('utf8') can also be used, produces same result// convert string back to buffer to consume it in Crypto.createDecipherivconstivBuffer=Buffer.from(iv,'utf-8');
Expectation
IV & ivArrayBuffer above should be equal, but they aren't. The length & data both are different.
Goal
To convert an IV created from
Crypto.randomBytes(16)
to string & then convert it back to array buffer (whichCrypto.createDecipheriv()
can consume). Basically, we are sending IV in string format from the frontend & the backend will consume it to decipher data.Problem
When we convert this IV to string & then convert it back to ArrayBuffer, they aren't equal/same. This is causing issues in decrypting the encrypted data.
Expectation
IV
&ivArrayBuffer
above should be equal, but they aren't. The length & data both are different.Sharing an example of values here:
Reproduction
You can run the minimal sample app here where this issue is reproduced - https://github.com/gupta-ji6/react-native-test-app/blob/issue/utf8/cipher.ts
P.S. Let me know if I'm converting them incorrectly, I'm not hands-on with Node APIs.
Environment
same issue on RN 0.72.5 as well.
The text was updated successfully, but these errors were encountered: