0

我有一个注册表单,我正在使用 zend_auth 登录,以下是如何加密信息以实现安全登录:

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

到目前为止,我有以下注册方法:

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

我需要在此处为​​密码添加 SHA1 加密,但我不确定它的外观。任何帮助都是极好的。

谢谢

4

1 回答 1

2
$data = array(
    'first_name' => $first_name,
    'surname' => $surname,
    'email' => $email,
    'username' => $username,
    'password' => sha1($password.$salt),
    'salt' => $salt,
    'age' => $age,
    'gender' => $gender,
    'uni' => $uni,
);
于 2012-04-26T14:43:14.010 回答