xjtuwangke / passwordhash
Portable PHP password hashing framework
Installs: 128 633
Dependents: 1
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=5.3.3
This package is not auto-updated.
Last update: 2024-11-23 16:55:53 UTC
README
This is froked from hautelook/phpass , modified to static functions
This is Openwall's Phpass, based on the 0.3 release, but modernized slightly:
- Namespaced
- Composer support (Autoloading)
- PHP 5 style
- Unit Tested
The changes are minimal and only stylistic. The source code is in the public domain. We claim no ownership, but needed it for one of our projects, and wanted to make it available to other people as well.
Installation
Add this requirement to your composer.json
file and run composer.phar install
:
{
"require": {
"hautelook/phpass": "dev-master"
}
}
Usage
The following example shows how to hash a password (to then store the hash in the database), and how to check whether a provided password is correct (hashes to the same value):
<?php namespace Your\Namespace; use Hautelook\Phpass\PasswordHash; require_once(__DIR__ . "/vendor/autoload.php"); $passwordHasher = new PasswordHash(8,false); $password = $passwordHasher->HashPassword('secret'); var_dump($password); $passwordMatch = $passwordHasher->CheckPassword('secret', "$2a$08$0RK6Yw6j9kSIXrrEOc3dwuDPQuT78HgR0S3/ghOFDEpOGpOkARoSu"); var_dump($passwordMatch);