承接 tal7aouy/hashlib 相关项目开发

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

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

tal7aouy/hashlib

最新稳定版本:v1.0.0

Composer 安装命令:

composer require tal7aouy/hashlib

包简介

Generates strong, secure passwords that are resistant to brute-force attacks.

README 文档

README

The HashLib library provides a convenient and flexible way to generate, hash, and validate passwords with various options and requirements. It includes a trait named Hasher that defines password generation, validation, and requirement checking functionalities.

Table of Contents

  1. Introduction
  2. Installation
  3. Usage
  4. Methods
  5. Conclusion

Introduction

The HashLib library is designed to simplify password hashing and verification in PHP applications. It offers a trait called Hasher that can be easily incorporated into your own classes to handle password-related operations.

Installation

The library can be installed using Composer:

composer require tal7aouy/hashlib

Usage

Basic Hashing

use Tal7aouy\HashLib\HashLib;
$passwordHash = HashLib::getInstance();
$password = "my_secure_password";
$hashedPassword = $passwordHash::hash($password);

if ($passwordHash::verify($password, $hashedPassword)) {
    echo "Password is verified!";
} else {
    echo "Password verification failed.";
}

Hashing with Salt

use Tal7aouy\HashLib\HashLib;
$passwordHash = HashLib::getInstance();

$password = "my_secure_password";
$hashedData = $passwordHash::hashWithSalt($password);

if ($passwordHash::verifyWithSalt($password, $hashedData['hash'], $hashedData['salt'])) {
echo "Password is verified!";
} else {
echo "Password verification failed.";
}

Password Requirement Checking

use Tal7aouy\HashLib\HashLib;

$passwordValidator = HashLib::getInstance();
$passwordValidator->setUseLowerCase(true);
$passwordValidator->setUseUpperCase(true);
$passwordValidator->setUseNumbers(true);
$passwordValidator->setUseSymbols(true);

$password = "Complex@Passw0rd";
$result = $passwordValidator->meetsRequirements($password);

if ($result === true) {
echo "Password meets all requirements.";
} else {
echo "Password requirements not met: " . $result;
}

Methods

For a comprehensive list of methods and their descriptions, please refer to the full documentation.

Below is a quick overview of some of the key methods available in the HashLib library:

setLength

Set the minimum required length for generated passwords.

setUseLowerCase

Specify whether lowercase letters are required in generated passwords.

setUseUpperCase

Specify whether uppercase letters are required in generated passwords.

setUseNumbers

Specify whether numbers are required in generated passwords.

setUseSymbols

Specify whether symbols are required in generated passwords.

setPasswordRequirements

Set multiple password requirements at once.

generateSalt

Generate a random salt using base64 encoding.

isHashed

Check if a password is already hashed.

hash

Hash a password using the specified algorithm and options.

verify

Verify if a password matches a given hash.

hashWithSalt

Hash a password with a randomly generated salt.

verifyWithSalt

Verify if a password, when combined with a salt, matches a given hash.

setPassword

Set the password to be used for hashing and validation.

getPassword

Get the currently set password.

meetsRequirements

Check if a given password meets the specified requirements.

For detailed usage instructions and examples, please see the Usage section above.

conclusion

Version: 1.0.0

License: MIT

For any questions, issues, or feedback, please reach out to the library's author, Mhammed Talhaouy.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-08-20