PHPackages                             whitehat101/apr1-md5 - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. whitehat101/apr1-md5

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

whitehat101/apr1-md5
====================

Apache's APR1-MD5 algorithm in pure PHP

v1.0.0(11y ago)349.7M—6.6%59MITPHPPHP &gt;=5.3.0

Since Feb 11Pushed 11y ago1 watchersCompare

[ Source](https://github.com/whitehat101/apr1-md5)[ Packagist](https://packagist.org/packages/whitehat101/apr1-md5)[ Docs](https://github.com/whitehat101/apr1-md5)[ RSS](/packages/whitehat101-apr1-md5/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (2)Used By (9)

Apache's APR1 MD5 Hashing Algorithm in PHP
==========================================

[](#apaches-apr1-md5-hashing-algorithm-in-php)

[![Build Status](https://camo.githubusercontent.com/0f342c2dbbb4af0e2632a898fba5603d8d2656ab5b0d9b24f0f3f5ce9c4005c3/68747470733a2f2f7472617669732d63692e6f72672f77686974656861743130312f617072312d6d64352e737667)](https://travis-ci.org/whitehat101/apr1-md5)

There is no way that the best way to generate Apache's apr1-md5 password hashes is from a [7-year-old comment on php.net](http://www.php.net/manual/en/function.crypt.php#73619). Only a n00b would trust a crypto algorithm from a non-security website's forum. Sadly, that is how the PHP community has accessed this algorithm, until now.

Here is a tested, referenced, documented, and packaged implementation of Apache's APR1 MD5 Hashing Algorithm in pure PHP.

Install
-------

[](#install)

composer.json:

```
{
    "require": {
        "whitehat101/apr1-md5": "~1.0"
    }
}
```

Use
---

[](#use)

```
use WhiteHat101\Crypt\APR1_MD5;

// Check plaintext password against an APR1-MD5 hash
echo APR1_MD5::check('plaintext', '$apr1$PVWlTz/5$SNkIVyogockgH65nMLn.W1');

// Hash a password with a known salt
echo APR1_MD5::hash('PASSWORD', '__SALT__');

// Hash a password with a secure random salt
echo APR1_MD5::hash('PASSWORD');

// Generate a secure random salt
echo APR1_MD5::salt();
```

The ideal `__SALT__` is an 8 character string. Valid salts are alphanumeric and `.` or `/`. Shorter salts are allowed. Longer salts are truncated after the 8th character.

Generate Hashes via Other Tools
-------------------------------

[](#generate-hashes-via-other-tools)

### htpasswd

[](#htpasswd)

```
$ htpasswd -nmb apache apache
apache:$apr1$rOioh4Wh$bVD3DRwksETubcpEH90ww0

$ htpasswd -nmb ChangeMe1 ChangeMe1
ChangeMe1:$apr1$PVWlTz/5$SNkIVyogockgH65nMLn.W1

$ htpasswd -nmb WhiteHat101 WhiteHat101
WhiteHat101:$apr1$HIcWIbgX$G9YqNkCVGlFAN63bClpoT/
```

### openssl

[](#openssl)

```
$ openssl passwd -apr1 -salt rOioh4Wh apache
$apr1$rOioh4Wh$bVD3DRwksETubcpEH90ww0

$ openssl passwd -apr1 -salt PVWlTz/5 ChangeMe1
$apr1$PVWlTz/5$SNkIVyogockgH65nMLn.W1

$ openssl passwd -apr1 -salt HIcWIbgX WhiteHat101
$apr1$HIcWIbgX$G9YqNkCVGlFAN63bClpoT/
```

Testing
-------

[](#testing)

```
composer install
vendor/bin/phpunit
```

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity55

Moderate usage in the ecosystem

Community18

Small or concentrated contributor base

Maturity58

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

Unknown

Total

1

Last Release

4114d ago

### Community

Maintainers

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

---

Top Contributors

[![whitehat101](https://avatars.githubusercontent.com/u/1093593?v=4)](https://github.com/whitehat101 "whitehat101 (10 commits)")

---

Tags

MD5apr1

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/whitehat101-apr1-md5/health.svg)

```
[![Health](https://phpackages.com/badges/whitehat101-apr1-md5/health.svg)](https://phpackages.com/packages/whitehat101-apr1-md5)
```

###  Alternatives

[maize-tech/laravel-markable

Laravel Markable

755229.4k](/packages/maize-tech-laravel-markable)

PHPackages © 2026

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