PHP equivalent of MySQL password()


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. // for mysql password
  2. function mysql_password($password)
  3. {
  4. $nr = 1345345333;
  5. $add = 7;
  6. $nr2 = 0x12345671;
  7. for ($i = 0; $i < strlen($password); $i++)
  8. {
  9. if ($password[$i] == ' ' || $password[$i] == '\t')
  10. continue;
  11.  
  12. $tmp = ord($password[$i]);
  13. $nr ^= (($nr & 63)+$add)*$tmp + ($nr << 8);
  14. $nr2 += ($nr2 << 8) ^ $nr;
  15. $add += $tmp;
  16. }
  17. $h1 = $nr & (1<<31) - 1;
  18. $h2 = $nr2 & (1<<31) - 1;
  19.  
  20. return sprintf("%08lx%08lx", $h1, $h2);
  21. }

URL: http://www.php-forum.com/phpforum/viewtopic.php?f=2&t=169

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.