PHPackages                             latgardi/password-tools - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. latgardi/password-tools

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

latgardi/password-tools
=======================

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

02PHPCI failing

Since Feb 28Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Latgardi/password-tools)[ Packagist](https://packagist.org/packages/latgardi/password-tools)[ RSS](/packages/latgardi-password-tools/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)DependenciesVersions (1)Used By (0)

PasswordTools
=============

[](#passwordtools)

**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
--------

[](#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
------------

[](#installation)

You can install the package via Composer:

```
composer require latgardi/password-tools
```

---

Usage
-----

[](#usage)

### Calculating Password Entropy:

[](#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

[](#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

[](#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
-----

[](#tests)

Run `composer test`

License
-------

[](#license)

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

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity15

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/fb346bbf4334e8ddc50bddd86f7bb3f4b9fb130153a94e8fe5688939599d0f5e?d=identicon)[Latgardi](/maintainers/Latgardi)

---

Top Contributors

[![lasaczka](https://avatars.githubusercontent.com/u/85876063?v=4)](https://github.com/lasaczka "lasaczka (5 commits)")

### Embed Badge

![Health badge](/badges/latgardi-password-tools/health.svg)

```
[![Health](https://phpackages.com/badges/latgardi-password-tools/health.svg)](https://phpackages.com/packages/latgardi-password-tools)
```

###  Alternatives

[webmozart/assert

Assertions to validate method input/output with nice error messages.

7.6k894.0M1.2k](/packages/webmozart-assert)[bensampo/laravel-enum

Simple, extensible and powerful enumeration implementation for Laravel.

2.0k15.9M104](/packages/bensampo-laravel-enum)[swaggest/json-schema

High definition PHP structures with JSON-schema based validation

48612.5M73](/packages/swaggest-json-schema)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[ashallendesign/laravel-config-validator

A package for validating your Laravel app's config.

217905.3k5](/packages/ashallendesign-laravel-config-validator)[crazybooot/base64-validation

Laravel validators for base64 encoded files

1341.9M8](/packages/crazybooot-base64-validation)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
