Search code examples
zend-frameworkzend-formzend-db

Registration form with salt and SHA1 encryption


I have a registration form and I am using zend_auth for my login, below is how the information is encrypted for secure login:

->setCredentialTreatment('SHA1(CONCAT(?,salt))');

I have the following register method so far:

public function addUser($first_name, $surname, $email, $username, $password, $salt, $age, $gender, $uni) {

    $salt=substr(SHA1(mt_rand()),0,40);

    $data = array(
        'first_name' => $first_name,
        'surname' => $surname,
        'email' => $email,
        'username' => $username,
        'password' => $password,
        'salt' => $salt,
        'age' => $age,
        'gender' => $gender,
        'uni' => $uni,
    );
    $this->insert($data);
} 

I need to add in the SHA1 encryption for the password here, but I am unsure how it will look. Any help would be awesome.

Thanks


Solution

  • $data = array(
        'first_name' => $first_name,
        'surname' => $surname,
        'email' => $email,
        'username' => $username,
        'password' => sha1($password.$salt),
        'salt' => $salt,
        'age' => $age,
        'gender' => $gender,
        'uni' => $uni,
    );