承接 zubzet/password-hash-utilities 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

zubzet/password-hash-utilities

最新稳定版本:1.0.0

Composer 安装命令:

composer require zubzet/password-hash-utilities

包简介

README 文档

README

Best enjoyed with zubzet/framework, this utility adds support for custom hashing algorithms, the default being bcrypt, and logic implementations. Keep your passwords safe and resistant to rainbow tables.

zubzet/password-hash-utilities changed my life

— Adrian

System requirements

  • PHP version has to be at least 8.0.0

Installation

Using Composer:

composer require zubzet/password-hash-utilities

Examples

Basic usage

require_once __DIR__."/../vendor/autoload.php";

use ZubZet\Utilities\PasswordHash\PasswordHash;

$password = PasswordHash::create("password123");
$check = PasswordHash::check(
    "password123",
    $password->hash,
    $password->salt,
    $password->hashingName
);

var_dump($check->matches);

Advanced usage

require_once __DIR__."/../vendor/autoload.php";

use ZubZet\Utilities\PasswordHash\PasswordHash;

// Set a custom CharUniverse
PasswordHash::setCharacterUniverse(range("a", "z"));

PasswordHash::setHashingAlgorithm(
    "bcryptExpensive",
    function($input) {
        return password_hash($input, PASSWORD_BCRYPT, [
            "cost" => 12
        ]);
    },
    function($input, $hash) {
        return password_verify($input, $hash);
    }
);

PasswordHash::defineCustomLogic("reverse", function($input, $salt, $pepper) {
    $input .= $salt.$pepper;
    return strrev($input);
});

$password = PasswordHash::create(
    "password123",
    hashingName: "bcryptExpensive",
    customLogicName: "reverse",
);

$check = PasswordHash::check(
    "password123",
    $password->hash,
    $password->salt,
    $password->hashingName,
    $hashingNameTarget = "bcrypt",
    $password->customLogicName,
    $customLogicNameTarget = "0.9",
);

// This will only be true if the password also matches
if($check->hasUpdate) {
    // Replace
    $password->hash;
    $password->salt;
    $password->hashingName;
    $password->customLogicName;
}

if($check->matches) {
    // Access granted
} else {
    // Password is wrong
}

var_dump($check);

统计信息

  • 总下载量: 57.21k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2022-04-16