latgardi/password-tools 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

latgardi/password-tools

Composer 安装命令:

composer require latgardi/password-tools

包简介

A lightweight PHP package to calculate password strength using entropy, with ASCII visualization and validation rules.

README 文档

README

PasswordTools is a lightweight PHP package for calculating password strength, validating passwords, and visualizing their entropy.

Package doesn't use any external packages.

It provides tools to evaluate password complexity and ensure compliance with security requirements.

Features

  • Entropy Calculation: Calculate the entropy of a password to measure its complexity.
  • Password Validation: Validate passwords against customizable requirements (e.g., length, uppercase, numbers, special characters).
  • Brute-Force Resistance: Estimate the average number of brute-force attempts required to guess a password.
  • Visualization: Generate a visual meter to represent password strength.

Installation

You can install the package via Composer:

composer require latgardi/password-tools

Usage

Calculating Password Entropy:

use Latgardi\PasswordTools\EntropyCalculator;

$entropy = EntropyCalculator::calculateEntropy(password: 'StrongPassword123!');
echo "Entropy: {$entropy->bits} bits\n";
echo "Strength Level: {$entropy->strengthLevel->name}\n";

// or
$entropyCalculator = new EntropyCalculator();
$entropy = $entropyCalculator->calculate(password: 'StrongPassword123!')

Validating a Password

use Latgardi\PasswordTools\Validator;
use Latgardi\PasswordTools\Type\ValueObject\PasswordRequirements;
use Latgardi\PasswordTools\Enum\StrengthLevel
$validator = new Validator(
    new PasswordRequirements(
        minLength: 10,
        requireNonASCIICharacters: true,
        minStrength: StrengthLevel::Strong
    )
);
$isValid = $validator->validate(password: 'StrongPaśśwŋrð123!');

if ($isValid) {
    echo "The password is valid.\n";
} else {
    echo "The password is invalid.\n";
}

// or
$entropyCalculator = new EntropyCalculator();
$entropy = $entropyCalculator->calculate(password: 'StrongPaśśwŋrð123!')
$isValid = Validator::validatePassword(password: 'StrongPaśśwŋrð123!')

Visualizing Password Strength

use Latgardi\PasswordTools\Visualizer;
use Latgardi\PasswordTools\Type\ValueObject\Entropy;

$entropy = new Entropy(64.0);
$meter = Visualizer::getEntropyMeter(entropy: $entropy);
$meter->render(); // Output: █████░░░░░

Tests

Run composer test

License

This project is licensed under 3-Clause BSD License. See the LICENSE file for details.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2025-02-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固