mysql old_passwords때문에 난감할 때

출처 : http://dev.mysql.com/doc/refman/5.0/en/password-hashing.html

php로 바꿔주자


function mysql_new_password( $pw ) {
    return strlen($pw)>0?strtoupper(‘*’.sha1(sha1($pw,true))):($pw=== null?null:”);
}



[출처] PHP5 에서 mysql password 구현 (old_password 아님)|작성자 파란천사

function mysql_41_password($in)
{
$p=sha1($in,true);
$p=sha1($p);
return “*”.strtoupper($p);
}


“mysql old_passwords때문에 난감할 때”에 대한 한개의 댓글

  1. function mysql_41_password($pw)
    {^M
    if (strlen($pw) > 0) {^M
    if (substr($pw,0,1) == “*”) ^M
    return $pw;^M
    else^M
    return strtoupper(‘*’.sha1(sha1($pw,true))); ^M
    }^M
    else {^M
    return null;^M
    }^M

    }

댓글이 닫혀있습니다.