moderndeveloperllc/scrypt
Composer 安装命令:
composer require moderndeveloperllc/scrypt
包简介
Class to generate scrypt password hashes that are compatible with the wg/scrypt Java implementation
README 文档
README
Abandonware
Much like ZF2, this library is consigned to the history books. Use the much better and faster password_hash() in PHP with the PASSWORD_ARGON2ID algorithm.
This class is an additional library (much like Zend\Crypt\Password\Bcrypt) used to generate scrypt password hashes that are compatible with the wg/scrypt Java implementation. While it uses Zend\Crypt\Key\Derivation\Scrypt, it also adds the parameters to the returned string that are required to compare password hashes. Also included is a function to check the type of hash on your passwords. Useful if you are transitioning gradually from bcrypt to scrypt hashes.
While this library uses two Zend Framework 2 modules (Crypt and Math), there should be no impediment to using this in other frameworks or projects that utilize composer.
Installing via Composer
Install composer in a common location or in your project:
curl -s http://getcomposer.org/installer | php
Create the composer.json file as follows:
{
"require": {
"moderndeveloperllc/scrypt" : "^1.0"
}
}
Run the composer installer:
php composer.phar install
Usage
Hash a password
<?php
use ModDev\Password\Scrypt;
$scrypt = new Scrypt();
$securePass = $scrypt->create('user password');
Check the hashed password against an user input
<?php
use ModDev\Password\Scrypt;
$scrypt = new Scrypt();
$securePass = 'the stored scrypt value';
$password = 'the password to check';
if ($scrypt->verify($password, $securePass)) {
echo "The password is correct! \n";
} else {
echo "The password is NOT correct.\n";
}
Optional Parameters
<?php
use ModDev\Password\Scrypt;
$scrypt = new Scrypt(array(
'cpuDifficulty' => 16384, //The CPU difficulty. Also called "N" in scrypt documentation. Must be a power of 2.
'memoryDifficulty' => 8, //The memory difficulty. Also called "r" in scrypt documentation.
'parallelDifficulty' => 1, //The parallel difficulty. Also called "p" in scrypt documentation.
'keyLength' => 32, //The key length. Must be greater or equal to 16.
));
Return the hash algorithm
<?php
use ModDev\Password\Scrypt;
$scrypt = new Scrypt();
$passwordhashType = $scrypt->getHashType($hashedPassword);
Check if the password needs rehashing
<?php
use ModDev\Password\Scrypt;
$scrypt = new Scrypt();
echo $scrypt->needsRehash($hashedPassword);
moderndeveloperllc/scrypt 适用场景与选型建议
moderndeveloperllc/scrypt 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 24.46k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2014 年 12 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「security」 「password」 「hashing」 「scrypt」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 moderndeveloperllc/scrypt 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 moderndeveloperllc/scrypt 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 moderndeveloperllc/scrypt 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A hashing library that will generate and add hashes to your laravel models.
Simple bundle for adding encryption type to Doctrine
The PHP class PasswordGenerator serves as a password generator to create memorable passwords like the keychain of macOS ≤ 10.14 did.
Provide a way to secure accesses to all routes of an symfony application.
Laravel middleware to restrict a site or specific routes using HTTP basic authentication
High-level cryptographic primitives and security utilities for Maatify systems including password hashing, reversible encryption, HKDF key derivation, and key rotation.
统计信息
- 总下载量: 24.46k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 22
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: BSD-3
- 更新时间: 2014-12-19