Codeigniter Ion Auth生成密码

时间:2015-01-17 10:38:57

标签: php codeigniter ion-auth

在我正在制作的应用程序中,我需要编辑并使用急速创建一些密码,我想我找到了一种方法,但我怀疑它的正确性。

我挖掘了离子身份验证并在ion_auth_model

中找到了此功能
/**
     * Hashes the password to be stored in the database.
     *
     * @return void
     * @author Mathew
     **/
    public function hash_password($password, $salt=false, $use_sha1_override=FALSE)
    {
        if (empty($password))
        {
            return FALSE;
        }

        //bcrypt
        if ($use_sha1_override === FALSE && $this->hash_method == 'bcrypt')
        {
            return $this->bcrypt->hash($password);
        }


        if ($this->store_salt && $salt)
        {
            return  sha1($password . $salt);
        }
        else
        {
            $salt = $this->salt();
            return  $salt . substr(sha1($salt . $password), 0, -$this->salt_length);
        }
    }

并通过在我的一个控制器中创建此公共函数进行测试

public function Qpass_gen(){
    $pass = $this->ion_auth_model->hash_password('password',FALSE,FALSE);
    echo $pass;
    }

当我将Qpass_gen()字符串替换为ion_auth默认存储在数据库中的字符串时,我设法登录。

我的快速生成密码的方法是否始终有效?

0 个答案:

没有答案
相关问题