How to decrypt a “sha512” encrypted variable?

瘦欲@ 提交于 2019-12-02 08:14:34
RiggsFolly

And you dont need to jump through all those hoops to use password_hash and this is how to check that an entered password matches the previously hashed password

The point of a HASH is it cannot (within a sensable time frame) be converted back to its original value. Instead you have to compare it using password_verify() to the unhashed value the user enters when they return and attempt to login using the same password.

$password = 'vancab123';

$hashed_pwd = password_hash($password);

// test the hashed password

if ( password_verify($password, $hashed_pwd) ) {
    //password entered is OK
} else {
    //password entered is WRONG
}

ADDITION after you clarified your question:

Read this for a Remember me functionality What is the best way to implement "remember me" for a website?

A hash is a one way transformation of an arbitrary value. They are by nature irreversible. In your case you will have to hash the password provided by the user, retrieve the value from the db, and do the comparison of both hashed values.

The only alternative would be the paradigm behind a rainbow attack, in which you hash every conceivable possibility and store them as key value pairs, but that is a lot of data.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!