php equivalent for mysql "password"

A

Anonymous

Guest
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
 
dvdbinternet said:
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
Hi!
Yes you can find info about encrypting passwod at http://www.mysql.com/documentation/mysql/full/
 
from a newsgroup:

This function will do the same thing:

Code:
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);
 }

Greetz Daan
 
dvdbinternet said:
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
Wait a minutes, you need encrypt a password and insert to MySQL db?
 
yep, but I want to encrypt the password before the query is build because of the dynamic structure in my pages.
It was easyer for me to encrypt it first and the send it to the database then to adjust the code for building the query.

Greetz Daan
 
Back
Top