Update old stored md5 passwords in PHP to increase security

前端 未结 4 996
花落未央
花落未央 2021-01-07 10:18

At the moment I have a database with md5 passwords stored, a few years back this was considered a little more secure than it is now and it\'s got to the point where the pass

4条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-07 10:39

    I looked into this subject a while back and found the following link of great use:

    Secure hash and salt for PHP passwords

    I also use the following to create a random salt:

    public static function getRandomString($length = 20) {
        $characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
        $string = '';
        for ($i = 0; $i < $length; $i++) {
            $string .= substr($characters, (mt_rand() % strlen($characters)), 1);
        }
        return $string;
    }
    

提交回复
热议问题