PHPackages                             crudle/phash - 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. crudle/phash

ActiveLibrary[Security](/categories/security)

crudle/phash
============

A password hash class

v1.0(9y ago)016MITPHPPHP &gt;=7.0

Since Dec 5Pushed 9y ago2 watchersCompare

[ Source](https://github.com/CrudleApps/phash)[ Packagist](https://packagist.org/packages/crudle/phash)[ RSS](/packages/crudle-phash/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Overview
--------

[](#overview)

`Crudle\Phash` provides a convenient wrapper class for the native `password_hash` functions. The primary benefit of this is the ability to remain object oriented.

Install
-------

[](#install)

`composer require crudle/phash`

Usage
-----

[](#usage)

The simplest usage of `PasswordHash` is indeed that; simple!

```
$hash = new PasswordHash('mypassword');
```

The string `'mypassword'` will be hashed and stored in the object. If you provide an already hashed string, the value will just be stored and no hashing will occur.

```
// This works too! This is the hash that was generated from 'mypassword'
$hash = new PasswordHash('$2y$10$F4L/hmnkYOSvGqU0tI4DuuszxFarOedNQA1Ws.ZHwKcRLmUlWaDTW');
```

Once you've created the PasswordHash object (either from a raw password or a hashed string), you can perform all the native operations on it:

```
$hash = new PasswordHash('$2y$10$F4L/hmnkYOSvGqU0tI4DuuszxFarOedNQA1Ws.ZHwKcRLmUlWaDTW');
$hash->verify('mypassword'); // Throws an InvalidPasswordException if validation fails
```

#### Retrieving the hash

[](#retrieving-the-hash)

Hashing a password is pretty useless unless we can store it for later validation. Thankfully, we can just cast the object to a string and we'll get our hash.

```
$passwordHash = new PasswordHash('mypassword');
$hash = (string) $passwordHash;
```

#### Extra config

[](#extra-config)

By default, the package uses the `PASSWORD_DEFAULT` hashing algorithm. If you want to change that, or any hashing options, you can provide a custom `Config` object to the `PasswordHash` constructor.

```
$config = new Config(PASSWORD_BCRYPT, ['cost' => 12]);
$hash = new PasswordHash('mypassword', $config);
```

#### Available methods

[](#available-methods)

```
$hash->verify('mypassword'); // throws InvalidPasswordException
$hash->needsRehash(); // throws HashValidationException
$hash->getInfo(); // returns an array of config info
$hash->__toString(); // returns the hash string
```

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

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

Unknown

Total

1

Last Release

3494d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/20602309?v=4)[crudle-apps](/maintainers/crudle-apps)[@crudle-apps](https://github.com/crudle-apps)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/crudle-phash/health.svg)

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

###  Alternatives

[mews/purifier

Laravel 5/6/7/8/9/10 HtmlPurifier Package

2.0k18.0M138](/packages/mews-purifier)[paragonie/ecc

PHP Elliptic Curve Cryptography library

25772.0k36](/packages/paragonie-ecc)

PHPackages © 2026

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