Reputation: 14229
I'd would like to encrypt in a database the password by using SHA-256 algorithm. I have made some researches and I found out I should use MessageDigest
class to encrypt properly a string object. The problem is how should revert the hash function to get back to the original password? I mean If I would create a login system, I have to be able to get back to the original password or maybe not? Maybe when the password is filled into the form, it has to be converted into hash function and compared to the hash string stored in database, right?
Upvotes: 0
Views: 4514
Reputation: 6357
Brother, the entire purpose of hashes is that you should not be able to get the original string back from them. What you need to do in case of passwords is you hash the user input and compare it with the hash of the password to check if it was the original password. To know how you convert the password into a SHA-256 hash read this.
Upvotes: 5