Is there a php-equivalent function for the mysql function "password" ??
This way I don't have to run a mysql-query to encrypt a password.
Greetz Daan
Moderators: macek, egami, gesf
dvdbinternet wrote:Is there a php-equivalent function for the mysql function "password" ??
This way I don't have to run a mysql-query to encrypt a password.
Greetz Daan

function mysql_password($password)
{
$nr = 1345345333;
$add = 7;
$nr2 = 0x12345671;
for ($i = 0; $i < strlen($password); $i++)
{
if ($password[$i] == ' ' || $password[$i] == '\t')
continue;
$tmp = ord($password[$i]);
$nr ^= (($nr & 63)+$add)*$tmp + ($nr << 8);
$nr2 += ($nr2 << 8) ^ $nr;
$add += $tmp;
}
$h1 = $nr & (1<<31) - 1;
$h2 = $nr2 & (1<<31) - 1;
return sprintf("%08lx%08lx", $h1, $h2);
}dvdbinternet wrote:Is there a php-equivalent function for the mysql function "password" ??
This way I don't have to run a mysql-query to encrypt a password.
Greetz Daan

function password($str) { return '*'.strtoupper(sha1(pack('H*',sha1($str)))); }
Return to PHP coding => General
Users browsing this forum: No registered users and 2 guests