Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting "Error: Invalid encrypted text received. Decryption halted" while decryption #26

Closed
email2smohanty opened this issue May 14, 2020 · 8 comments
Labels

Comments

@email2smohanty
Copy link

I am getting "Error: Invalid encrypted text received. Decryption halted" while decryption. Please note that same encrypted value is getting decrypted successfully in one setup(vm) but its not working in another setup(vm), my _secretKey is same I have not changed any thing.

What could be the reason?

@danang-id
Copy link
Owner

danang-id commented May 14, 2020

Could you give more information regarding this issue as follows.

  1. The simple-crypto-js version you are using.
  2. Steps to reproduce the error.

@email2smohanty
Copy link
Author

My simple-crypto-js version is "2.2.0" in both the env.

Steps to reproduce:
Env1 where encryption and decryption is working as expected:
In this env my simple-crypto-js version is "2.2.0", node version is "10.16.0" and npm version is "6.9.0". I have one encrypted token value which is encrypted using secretKey "abc" and here encryption and decryption is working fine.

Env2 where encryption and decryption is not working as expected:
In this env my simple-crypto-js version is "2.2.0", node version is "8.17.0" and npm version is "6.14.4". While decrypting the same encrypted token value using same secretKey "abc" I am geting "Error: Invalid encrypted text received. Decryption halted"

@danang-id
Copy link
Owner

danang-id commented May 16, 2020

@email2smohanty I believe your information is invalid in the Env2.

The error Invalid encrypted text received. Decryption halted. is a new kind of error that will only occurs on simple-crypto-js version 2.4.0 or newer. This error will never be thrown if you are using simple-crypto-js version 2.2.0.

Here are few things to mitigate the issue.

  1. Make sure the encrypted token you trying to decrypt is really the one encrypted by simple-crypto-js.
  2. If the simple-crypto-js you use to decrypt is a version prior to 2.3.0, make sure that you also use simple-crypto-js version 2.2.0 or older to do the encryption. It is because since simple-crypto-js version 2.3.0, there was a change in the encryption algorithm that breaks the decryption support of 2.2.0 or older. That means, anything encrypted with simple-crypto-js version 2.3.0 or newer will not be able to be decrypted with simple-crypto-js version 2.2.0 or older. Vice versa, anything encrypted with simple-crypto-js version 2.2.0 or older will not be able to be decrypted with simple-crypto-js version 2.3.0 or newer. Please read more about that here.

@email2smohanty
Copy link
Author

Yes you are correct my simple-crypto-js version was not correct in both the env's hence it was failing, now working so closing this issue.

Thanks for your hint and quick response.

@zhamidi
Copy link

zhamidi commented Sep 21, 2020

Hey there, I have the same issue but in my case I am using version 3.0.0 to both encrypt and decrypt.
What I do is that using node I encrypt with a 64 byte key, then I save both the cipher text and the key to individual files.
For the decryption part I do it on the browser side. I make a get request using Axios to fetch my two files. I log both strings, and they are the same as the ones in the file.
I have been on this for days now. Do you want me to provide my code so you can see better?

@zhamidi
Copy link

zhamidi commented Sep 24, 2020

I solved my problem it's fine

@amitvchaudhary
Copy link

@zhamidi Could you please tell me how you fixed the issue? I am also using ^3.0.0 and facing the same issue.

@zhamidi
Copy link

zhamidi commented Oct 15, 2020

@amitvchaudhary Well what I found out is that when I fetch my encrypted file with Axios, somehow there are quotes that are added to the string, so I removed them using cryptedjs.substr(0, cryptedjs.length)
But the problem was not coming from the simple-crypto library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants