+ 1
String encryption in javascript
Im working on small questionaire type of game and would like to hide the correct answer for user looking at the source code. The correct answer is store in an object along with the question. I want to encrypt the correct answer and then either decrypt it or encrypt the user answer and compare. Which library provide a simple way to implement this or any suggestion on another way to approach this
3 Answers
+ 1
If you dont need the real answer any more and just want to compare with the input i would use hash functions like SHA
They are also used for storing passwords to prevent others to see the real password
+ 1
A hash function always has the same output for the same input and if its a good hash function you dont know the input if you know the output
- 1
Thank you Jnn after looking for the hash function in the doc didnt find any but instead SubtleCrypto hover it seams a bit too much for what i need however i found an implementation of the java hash function in for javascript thank a lot will try it.