Click here to Skip to main content
15,662,459 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I'm working on AES encryption

I want to encrypt a string in JavaScript and using that ciphertext which is generated during encryption I want to decrypt it in JAVA. I want to use static SALT and IV on both side i.e. common SALT and IV.

What actually I want is to avoid the use of API calls and do it using static IV and Salt

What I have tried:

I encrypted the string in javaScript and decrypted in JAVA but using random SALT and IV and not static and by using API calls for sending the encrypted text and salt and IV to the java program.

Using JavaScript HTTP.
Updated 3-Jun-19 4:42am

Any keys\secrets you use to encrypt data in javascript are visible by the client which is why people don't user javascript for encryption. To preempt your next question, no you can't stop people looking at the javascript\secrets, you can't disable view source, you can't disable the browser tools.
Share this answer
Yes ... but it's not a good idea.

Remember, Javascript is interpreted in the browser - so the full code is sent to the client in a human readable form, which can be viewed in detail by anyone with access to an F12 key.
So static salt in JS is pretty much the same as "no salt" because it is going to be visible to anyone who might want to crack your encryption. And you will need to be pretty careful what key you are using as well.

I'd strongly suggest using an secure HTTPS connection at all times, and doing the actual encryption at the server end rather than the client - that way the salt, IV, and key are not exposed to everybody and your system should be more secure.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900