PHPackages                             jabarihunt/password - 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. [Security](/categories/security)
4. /
5. jabarihunt/password

ActiveLibrary[Security](/categories/security)

jabarihunt/password
===================

Simple Password class.

v1.0.1(6y ago)030MITPHPPHP &gt;=5.4.0

Since Dec 7Pushed 6y ago1 watchersCompare

[ Source](https://github.com/jabarihunt/password)[ Packagist](https://packagist.org/packages/jabarihunt/password)[ Docs](https://github.com/jabarihunt/password)[ RSS](/packages/jabarihunt-password/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (2)DependenciesVersions (3)Used By (0)

Password Class
==============

[](#password-class)

This is a simple class that uses the standard PHP methods *[password\_hash()](http://php.net/manual/en/function.password-hash.php)* and *[password\_verify()](http://php.net/manual/en/function.password-verify.php)* to create a hashed password and compare the hash to entered passwords respectively. The primary purpose of this class is to remove some of the boilerplate code required when performing these password operations.

The class defaults to using the default algorithm that PHP selects (per version) and a cost of 10. Both can be set when creating the hash.

> ***NOTE:*** It is recommended that database columns that store hashes created with `password_hash()` are at least 255 characters wide, as the length of hashes will grow in future versions of PHP!

INSTALLING
----------

[](#installing)

#### Via Composer

[](#via-composer)

Run the following command in the same directory as your composer.json file:

`php composer.phar require jabarihunt/password`

#### Via Github

[](#via-github)

1. Clone this repository into a working directory: `git clone git@github.com:jabarihunt/password .`
2. Include the Password class in your project...

```
require('/path/to/Password.php')
```

...or if using an auto-loader...

```
 use jabarihunt/Password;
```

USAGE
-----

[](#usage)

The `Password::create()` and `Password::compare()` methods will throw exceptions if invalid data is passed to them, so be sure to use try/catch blocks!

#### Creating Password Hashes

[](#creating-password-hashes)

```

```

```
/* OUTPUT*/
hash1: $2y$10$lqfDbrxDEwnw34uaJCBN4OLatL3XKWnxuIwBTHqhcY5NVvvljlnd6
hash2: $2y$10$2b2nHGE1Jx58AyHxVwWiq.EC039DNB9HLzcY.3b7tpEdIvLg6j30q
hash3: $2y$12$e284Os/7zD4MsxXFX9h5UuKj3disIkmOkIJRzj4CnMoT3np7tyD2y

```

#### Comparing Passwords And Hashes

[](#comparing-passwords-and-hashes)

Using our first hash from above...

```

```

```
/* OUTPUT*/
/var/www/html/controllers/HomeController.php:7:boolean true

```

#### Validating Passwords

[](#validating-passwords)

There is a third method, `Password::isValid()`, that validates if a password follows the below rules and returns a `boolean`. Eventually I'll add functionallity to pass your own rules. This method doesn't throw any exceptiones.

**Password Rules:**

- Is not empty
- Contains at least 8 charatcters
- Contains at least 1 uppercase letter
- Contains at least 1 lowercase letter
- Contains at least 1 number
- Contains at least 1 symbol

You can optionally pass a second `string` parameter called `$username` that will make sure the password does not contain the username (or whatever the passed string contains).

```

```

```
/* OUTPUT*/
/var/www/html/controllers/HomeController.php:8:boolean false
/var/www/html/controllers/HomeController.php:9:boolean true
/var/www/html/controllers/HomeController.php:10:boolean false

```

CONTRIBUTING
------------

[](#contributing)

1. Fork Repository
2. Create a descriptive branch name
3. Make edits to your branch
4. Squash (rebase) your commits
5. Create a pull request

LICENSE
-------

[](#license)

This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~491 days

Total

2

Last Release

2224d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2807764?v=4)[Jabari J. Hunt](/maintainers/jabarihunt)[@jabarihunt](https://github.com/jabarihunt)

---

Top Contributors

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

---

Tags

securitypassword

### Embed Badge

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

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

###  Alternatives

[rych/phpass

PHP Password Library: Easy, secure password management for PHP

248801.7k4](/packages/rych-phpass)[bordoni/phpass

Portable PHP password hashing framework

244.4M26](/packages/bordoni-phpass)[jeremykendall/password-validator

Password Validator validates password\_hash generated passwords, rehashes passwords as necessary, and will upgrade legacy passwords.

14469.9k3](/packages/jeremykendall-password-validator)[mxrxdxn/pwned-passwords

A library to query Troy Hunt's Pwned Passwords service to see whether or not a password has been included in a public breach.

3270.9k2](/packages/mxrxdxn-pwned-passwords)[spooner-web/be_secure_pw

You can set password conventions to force secure passwords for BE users.

10461.3k](/packages/spooner-web-be-secure-pw)[firehed/security

Security tools for PHP

2374.9k2](/packages/firehed-security)

PHPackages © 2026

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