Decrypt from SHA256

You cannot decrypt the result of a One Way Hash. What you should do instead is compare a hash of the entered password versus the stored hash in the database.

Example:

var password = "1234";
var hashedPassword = Sha256encrypt(password);

var allowLogin = hashedPassword == storedPassword; //storedPassword from Database, etc.

This is only the very basics though, when using hashing algorithms you should consider using a Salt too.

Leave a Comment