Secure password storage

前端 未结 7 931
别那么骄傲
别那么骄傲 2021-01-20 09:22

I\'m developing a web service where users must login. I will store user data in an SQL database and input/output via PHP. But I don\'t want to store it openly. How do I encr

7条回答
  •  不要未来只要你来
    2021-01-20 09:56

    There is the possibility to hash passwords (preferably with a salt):

    $salt = random_string($length = 5);
    $hash = $salt . sha1($salt . $password);
    

    Or store encrypted (only if your MySQL connection is SSL secured):

    INSERT INTO `user` (`user`,`pass`) VALUES("username",ENCRYPT("password","secretkey"))
    

提交回复
热议问题