michelonsouza / encrypt-storage

EncryptStorage provide a little more security in frontend
MIT License
266 stars 13 forks source link

Native crypto module could not be used to get secure random number. #534

Closed skp92 closed 1 year ago

skp92 commented 1 year ago

Having issue with crypto module, it could be an issue with crypto-js version. @michelonsouza can you please check this? I am using in React app Much thanks!

michelonsouza commented 1 year ago

Hello @skp92, how are you? What would be the specific problem? Can you post a print so I can check? What is your CRA version?

Thank you very much.

skp92 commented 1 year ago

Hello @skp92, how are you? What would be the specific problem? Can you post a print so I can check? What is your CRA version?

Thank you very much.

Hi @michelonsouza , Thanks for asking and checking this, I am doing good. Hope you are doing good. I am getting this Native crypto module could not be used to get secure random number. error while running tests, in test it is not able to set item using this encrypt-storage library. I believe this error is due to mock, but doesn't get it figured out yet. Did some random check, found couple of threads for cypto version compatibility issue. I don't use CRA, using react version 16.4.2

michelonsouza commented 1 year ago

I believe that this error is due to the volatility of the secret key.

Stores it in a constant that does not change at run time. When the CRA version (I believe you are using 4.0.0). In this version I use it normally. What can happen is that the test in localStorage is being mocked in the tests.

As I said before, I use it normally. Is your code in a public repository? If so, can you share the link?

skp92 commented 1 year ago

Secret key is a constant and stored in a file, and value I have been given the default - "secret-key-value" (As I had tested this with a test code with CRA and LS value was good with encryption). Code is not in public repo so can't share it. What kind of secret key is required?

michelonsouza commented 1 year ago

The secret key is an alphanumeric string containing at least 10 characters. @skp92

skp92 commented 1 year ago

The secret key is an alphanumeric string containing at least 10 characters. @skp92

Thank you, so it could be any alphanumeric string or there should be some rules with it?

michelonsouza commented 1 year ago

Yes @skp92

skp92 commented 1 year ago

Yes @skp92

@michelonsouza , tried with couple of alphanumeric strings with different lengths but getting same error in tests - Native crypto module could not be used to get secure random number.

What specific rules are there for this alphanumeric string, what kind of secret key are being expected?

michelonsouza commented 1 year ago

Please paste your package.json content here @skp92.

skp92 commented 1 year ago

Please paste your package.json content here @skp92.

Hi @michelonsouza , I am afraid in sharing package content it may violate the policy. I have figured out the way to surpass the encrypt/decrypt in tests.

michelonsouza commented 1 year ago

I'm sorry for this. I'll see if I can simulate this error posted here in this same issue.

If you have any problems, please contact me and I will respond as soon as possible.