MySQL ENCRYPT密码但是如何解密? [英] MySQL ENCRYPT password but how to DECRYPT?
问题描述
我正在阅读本教程,并且正在使用ENCRYPT MySQL函数.
I am going through this tutorial and I am using the ENCRYPT MySQL function.
但是现在我有一个问题,如何在MySQL或php中解密加密的密码?我想比较一下输入的密码是否与加密的密码相同.
But now I have the problem of how to decrypt the encrypted password in MySQL or in php? I want to compare if the password entered is the same as the encrypted one.
我该如何比较?必须使用ENCRYPT函数对MySQL进行加密!
How can I compare it? MySQL must be encrypted with the ENCRYPT function!
我正在搜索,但找不到任何有关如何解密ENCRYPT MySQL函数的信息...
I am searching but I can not find anything how to decrypt the ENCRYPT MySQL function...
推荐答案
ENCRYPT
is using a one way hash algorithm there is no DECRYPT
.. That's the sense of enrypting passwords: a hacker should have no option to see the clear text passwords.
当您需要将db中的密码与用户输入的密码进行比较时,请使用这样的查询(使用准备好的查询)
When you need to compare a password in db with one a user has entered, use a query like this (using prepared queries)
SELECT * FROM `user`
WHERE `name` = 'hek2mgl`
AND `password` = ENCRYPT('user_input', `password`)
ENCRYPT
函数将输出以盐本身为前缀的盐腌"字符串,因此将加密的密码反馈给它将重新提供原始盐.
The ENCRYPT
function will output a "salted" string prefixed with the salt itself, so feeding it back the encrypted password will re-supply the original salt.
这篇关于MySQL ENCRYPT密码但是如何解密?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!