j3j5/hmac-bcrypt-laravel
最新稳定版本:0.3
Composer 安装命令:
composer require j3j5/hmac-bcrypt-laravel
包简介
A laravel hasher for the HMAC-BCrypt implementation for password hashing
README 文档
README
This repository contains an implementation of the hmac-bcrypt password hashing function for the Laravel Framework. It is based on the reference implementation created by @epixoip (specifically the PHP one).
If you are asking yourself why, you can read the technical justification on the original implementation.
Installation
If you want to use it, you can use composer:
composer require j3j5/hmac-bcrypt-laravel
Configuration
On your config/hashing.php you can change the driver to hmac-bcrypt. In order to work, you need to set a pepper which should be a unique (per project) secret string. You have two options, either set HMAC_BCRYPT_PEPPER on your .env or as an environment variable, or add to your own hashing.php config file the following array:
'hmac-bcrypt' => [ 'pepper' => 'black-pepper' ],
The amount of rounds used by bcrypt is also customizable. You can use HMAC_BCRYPT_ROUNDS on your .env (or as environment variable) or add the key rounds to the hmac-bcrypt key on your hashing config.
'hmac-bcrypt' => [ 'rounds' => 15 ],
Use
Now you can use it like you would use the hasher on Laravel:
$clearTextPass = 'supersecret'; $hash = Hash::make($clearTextPass); // Now store it on the db
Later on...
if (Hash::check($clearTextPass, $hash)) { // eccoli qua! you can log in your user! // Check whether your settings have changed since last time if (Hash::needsRehash($hash)) { $newHash = Hash::make($clearTextPass); // Store the new hash on the db } }
Final notes
Although I tried to be very careful and thorough on the implementation, I made this driver for fun so use at your own risk. I encourage you to take a dive into the code to make sure I did not miss anything important or into the tests so you can check for yourself what currently works. Underneath it uses the native PHP functions for SHA512 hash_hmac() and crypt() for the Bcrypt encryption (with a salt generated by random_bytes()), so this is not a case of building your own crypto libraries but instead, using the already available ones.
j3j5/hmac-bcrypt-laravel 适用场景与选型建议
j3j5/hmac-bcrypt-laravel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 169 次下载、GitHub Stars 达 4, 最近一次更新时间为 2022 年 09 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 j3j5/hmac-bcrypt-laravel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 j3j5/hmac-bcrypt-laravel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 169
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 22
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-09-24