sha1不能使用密码加密

Ham*_*sha 3 php sha password-hash

我使用sha1加密来加密我的密码,但我遇到了问题.对于某些用户,登录无效.

我的代码,(注册时)

// all validation is done here
$password = sha1($_POST['password']);

// inserting data is here
Run Code Online (Sandbox Code Playgroud)

在登录我的查询是

$email     = $_POST['email'];
$password  = sha1($_POST['password']);

select * from users where email = $email and password = $password and status = 1 and deleted = 0;
Run Code Online (Sandbox Code Playgroud)

用户面临密码问题之一,

IM $$人

难道我做错了什么.

请帮我.

Sco*_*ski 6

我使用sha1加密来加密我的密码,

不.SHA1不是加密,它是一个哈希函数.了解加密和散列之间的区别对于安全地实现这一点至关重要:

此外,您编写查询的方式使我相信它易受SQL注入攻击.