danang-id / simple-crypto-js

Simplified AES cryptography for safer and easier encryption and decryption processes of any JavaScript objects.
https://simplecrypto.js.org
MIT License
85 stars 27 forks source link

Differents behavior on differents env #25

Closed enguerranws closed 4 years ago

enguerranws commented 4 years ago

Hi,

I'm having another issue.

• I have an API server, using Node / Express which uses your lib to encrypt data and put this encrypted data into a QR Code • I have a mobile app (React Native) which reads those QR Code and decrypt data using the same version of your lib, and the same code : they actually share the same JS module

Few days ago, the strangest thing happened. My Express app have 3 envs : local, develop, production. • on local, QR codes are working, data is encrypted (by my local server) and decrypted (by the mobile app) successfully When I log my simpleCrypto instance after setting it with a secret key and encrypted data, it returns something like this : {"_secret":"my-secret","_keySize":256,"_iterations":100,"_defaultEncoder":{}} • on production, QR codes are working, data is encrypted (by my local server) and decrypted (by the mobile app) successfully • on develop, Qr codes looks differents, and when I log simpleCrypto instance, with the same code (it actually is the same branch) it returns : {"_dataBuffer":"my-text-to-encrypt","_encoder":{},"_secret":{"words":[1411654652,1498173583,-882117861,-1761465478,-1507164864,-1303364673,-1856803349,-526043043,-333785183,190184971,-1097709156,1104822113,-274110398,1746094063,-1976477165,-629992992],"sigBytes":64},"_keySize":256,"_iterations":100}

What I don't understand is that my local and the dev have the same package.json, same package-json.lock, same Node version, same code, but simpleCrypto instances objects are not the same, and I really have no clue what can cause this.

It's more a question than an issue... But I'm looking for any idea :)

enguerranws commented 4 years ago

Nevermind, I guess I see the issue, it comes from my cloud service which is not handling properly my package.json / package-lock.json. I can see that _dataBuffer prop comes with 2.4.0, so my develop server is using another version of simple-crypto-js, when the rest of my stack is using 2.2.0(as of React Native use).