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 2mo ago

READMEChangelog (1)DependenciesVersions (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 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community2

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

3448d ago

### Community

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

[defuse/php-encryption

Secure PHP Encryption Library

3.9k162.4M214](/packages/defuse-php-encryption)[roave/security-advisories

Prevents installation of composer packages with known security vulnerabilities: no API, simply require it

2.9k97.3M6.4k](/packages/roave-security-advisories)[mews/purifier

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

2.0k16.7M113](/packages/mews-purifier)[robrichards/xmlseclibs

A PHP library for XML Security

41278.1M118](/packages/robrichards-xmlseclibs)[bjeavons/zxcvbn-php

Realistic password strength estimation PHP library based on Zxcvbn JS

86917.5M63](/packages/bjeavons-zxcvbn-php)[enlightn/security-checker

A PHP dependency vulnerabilities scanner based on the Security Advisories Database.

33732.2M110](/packages/enlightn-security-checker)

PHPackages © 2026

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