小编The*_*ish的帖子

Laravel 5:使用SHA1而不是Bcrypt

我正在尝试扩展HashServiceProviderlaravel 5中的默认Bcrypt ,以改为使用SHA1加密.

使用这个问题的答案:如何在Laravel 4中使用SHA1加密而不是BCrypt?http://laravel.com/docs/5.0/extending#container-based-extension上的官方文档,我设法编写以下代码:

app/Providers/ShaHashServiceProvider.php中


    use App\ShaHasher;
    use Illuminate\Hashing\HashServiceProvider;

    class ShaHashServiceProvider extends HashServiceProvider {

        public function boot()
        {
            parent::boot();

            $this->app->bindShared('hash', function()
            {
                return new ShaHasher();
            });
        }

    }

app/ShaHasher.php中


    use Illuminate\Contracts\Hashing\Hasher as HasherContract;

    class ShaHasher implements HasherContract {

        public function make($value, array $options = array()) {
            $value = env('SALT', '').$value;
            return sha1($value);
        }

        public function check($value, $hashedValue, array $options = array()) {
            return $this->make($value) === $hashedValue;
        }

        public …

php sha1 extending laravel laravel-5

6
推荐指数
1
解决办法
7341
查看次数

标签 统计

extending ×1

laravel ×1

laravel-5 ×1

php ×1

sha1 ×1