insomnius/aurphm
Composer 安装命令:
composer require insomnius/aurphm
包简介
Aurelia pseudo hashing method is my experimental function to hash password with HMAC (Hash-based message authentication code), PBKDF2 (Password-Based Key Derivation Function 2) and Pseudo Random Bytes.
README 文档
README
Aurelia pseudo hashing method (Aurphm) is my experimental function to hash password with HMAC (Hash-based message authentication code), PBKDF2 (Password-Based Key Derivation Function 2) and Pseudo Random Bytes. The main reason to create this library is to make good hash for security reason and the hash must be:
- Has a random salt every hash generation
- Has a user unique hash so it will generate differently if the key and credential is different using HMAC
- Has a unique signature for authentication using PBKDF2
- Has a different hash value every hash generation but still can be authenticated
- We can set their prefered algorithm for each method (salt, user unique, signature)
- Simple to authenticate
This library is inspired by a post in crackstation about how to make secure hash here.
How to use
Here is a simple step to generate a hash:
use Aurphm\Aurphm; $credential = "credential"; $key = "key"; $hash = Aurphm::hash($credential, $key); echo $hash;
The hash result will be random every generation and the one of the result is:
And there is an advanced configuration too, you can change how much iteration on PBKDF, the prefix, signature length, salt algorithm, algorithm for creating user unique hash and algorithm for signature.
Here is the example code:
$credential = 'credential'; $key = 'key'; $length = 128; $iteration = 64; $prefix = 'GITHUB'; $saltalgo = 'SHA1'; $useruniquealgo = 'SHA256'; $signaturealgo = 'MD5'; $hash = Aurphm::init()->setIteration($iteration) // You have to use ini to called this function statically, Set the iteration of pbkdf ->setPrefix($prefix) // Set the prefix of the hash ->setSignatureLength($length) // Set signature length ->setSaltAlgo($saltalgo) // Set salt hash algorithm ->setUserUniqueAlgo($useruniquealgo) // Set user unique hash algorithm (hmac algorithm) ->setSignatureAlgo($signaturealgo) // Set signature hash algorithm (pbkdf algorithm) ->hash($credential, $key); echo $hash;
And here is the result look like:
And lastly, how about authenticate? we can do that in simple way too like this:
$hash_value = 'AURPHM_e61ab31BBLABLABLABLABLABLABLABLA'; $key = 'key'; $credential = 'credential'; if(Aurphm::authenticate($credential, $key, $hash_value)) { echo "Authentication success!"; } else { echo "Authentication failed."; }
Download
You can download this package via github release or if you using composer just type this and the magic will do the work.
composer require insomnius/aurphm
Demo
You can also view the demo i made in demo folder using php development server, just type this in your command prompt or terminal (make sure you are in the root directory of this project):
php -S localhost:7800 -t ./demo/
And then open your browser with address http://localhost:7800.
That's it, have fun to use it! :)
insomnius/aurphm 适用场景与选型建议
insomnius/aurphm 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 647 次下载、GitHub Stars 达 13, 最近一次更新时间为 2018 年 01 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「security」 「hash」 「pbkdf」 「hmac」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 insomnius/aurphm 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 insomnius/aurphm 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 insomnius/aurphm 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Provide a way to secure accesses to all routes of an symfony application.
Article CSS-ID Frontend Output Optimization
♺ Laravel Nova Hashids card. Convert your ids.
It's a barebone security class written on PHP
Contao CMS integrity check for some files
A PHP security linter to detect insecure functions like var_dump, print_r, and other dangerous functions in your codebase
统计信息
- 总下载量: 647
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 14
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-01-17

