xaamin/hashing

密码散列

v1.0.3 2016-05-25 21:28 UTC

This package is auto-updated.

Last update: 2024-08-28 22:06:57 UTC


README

安装

使用composer安装包

    composer require xaamin/hashing

用法

您可以通过调用Hash实例上的make方法来散列密码。

    use Xaamin\Hashing\Hash;
    
    $password' => Hash::make('plain-text');

check方法允许您验证给定的明文字符串是否对应给定的散列。

    if (Hash::check('plain-text', $hashedValue)) 
    {
        // The passwords match...
    }

默认情况下,此包使用默认的PHP原生散列实现,这是散列密码最安全的方式,需要PHP 5 >= 5.5.0。无论如何,如果您使用的是PHP 5 < 5.5.0,则可以使用Bcrypt散列算法。我建议启用mcrypt或openssl PHP扩展来生成安全的随机盐。

   Hash::setHasher(new Xaamin\Hashing\Strategies\BcryptHash);