Zen Cart Logo
Forums / General Questions / Generate a password hash

Generate a password hash

Views: 1,595

Results 1 to 2 of 2
30 Jun 2011, 9:00 AM
#1
sacauntos avatar

sacauntos

New Zenner

Join Date:
Apr 2011
Posts:
4
Plugin Contributions:
0

Generate a password hash

Hello all!

I'd like to know how does Zen Cart generate the password hashes that are stored for every user in the 'customers' table in the database. I tried a simple MD5 hash of the password, but that doesn't quite seem to work.

Thanks in advance.

30 Jun 2011, 11:20 AM
#2
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Generate a password hash

  function zen_encrypt_password($plain) {
    $password = '';

    for ($i=0; $i<10; $i++) {
      $password .= zen_rand();
    }

    $salt = substr(md5($password), 0, 2);

    $password = md5($salt . $plain) . ':' . $salt;

    return $password;
  }