技术&日志

laravel-admin 加密方式

laravel-admin 加密的方式 laravel 密码加密

laravel-admin 密码加密用的是laravel中的bcrypt函数, 最后调用的是系统函数password_hash

\vendor\encore\laravel-admin\src\Console\CreateUserCommand.php
\vendor\laravel\framework\src\Illuminate\Foundation\helpers.php

\vendor\laravel\framework\src\Illuminate\Hashing\BcryptHasher.php

    /**
     * Hash the given value.
     *
     * @param  string  $value
     * @param  array   $options
     * @return string
     *
     * @throws \RuntimeException
     */
    public function make($value, array $options = [])
    {
        $hash = password_hash($value, PASSWORD_BCRYPT, [
            'cost' => $this->cost($options),
        ]);

        if ($hash === false) {
            throw new RuntimeException('Bcrypt hashing not supported.');
        }

        return $hash;
    }

    /**
     * Check the given plain value against a hash.
     *
     * @param  string  $value
     * @param  string  $hashedValue
     * @param  array   $options
     * @return bool
     */
    public function check($value, $hashedValue, array $options = [])
    {
        if (strlen($hashedValue) === 0) {
            return false;
        }

        return password_verify($value, $hashedValue);
    }

相关资料

laravel-admin 加密

发表评论