Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ozh/phpass
Openwall phpass, namespaced with composer
https://github.com/ozh/phpass
hash php phpass
Last synced: about 2 months ago
JSON representation
Openwall phpass, namespaced with composer
- Host: GitHub
- URL: https://github.com/ozh/phpass
- Owner: ozh
- Archived: true
- Created: 2017-05-17T22:36:41.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-02-23T15:39:06.000Z (almost 3 years ago)
- Last Synced: 2024-09-20T06:19:52.262Z (3 months ago)
- Topics: hash, php, phpass
- Language: PHP
- Homepage:
- Size: 37.1 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome - ozh/phpass - Openwall phpass, namespaced with composer (PHP)
README
Openwall Phpass, modernized
===========================[![Build Status](https://app.travis-ci.com/ozh/phpass.svg?branch=master)](https://app.travis-ci.com/github/ozh/phpass)
This is Openwall's [Phpass](http://openwall.com/phpass/), based on the 0.5 release, but modernized slightly:
- Namespaced
- Composer support (Autoloading)
- Unit TestedThe modernization has been done by Hautelook, from whom I stole this library to originally repackage it for PHP 5.3 to 7.0 compatibility in a single file and branch (Hautelook's port consisting of two branches, one for PHP 5.3 to 5.5, and another one for 5.6+).
Current version requires PHP 5.6+
## Installation ##
Add this requirement to your `composer.json` file and run `composer install`:
{
"require": {
"ozh/phpass": "1.3.0"
}
}## 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
HashPassword('secret');
var_dump($password);
// Will output something like:
// '$2a$08$a6XFLs8SrjClF1szoDDkI.6gtWVb4//QnzUjkxlus83AKCNjuD8Ha' (length=60)
// '$2a$08$Qze1smZ//VAwHJ1t52zklOY/yLwlbKR6Ighf6B7uqGXdYVozTPEdG' (length=60)
// '$2a$08$u2uKfE9igO.Cz0SptWxlXeVi0CQglfl3FdRK3YpbGm1NfF1d.CFPm' (length=60)// Decrypt
var_dump( $passwordHasher->CheckPassword('secret', '$2a$08$0RK6Yw6j9kSIXrrEOc3dwuDPQuT78HgR0S3/ghOFDEpOGpOkARoSu') );
// true
var_dump( $passwordHasher->CheckPassword('secret', '$2a$08$Qze1smZ//VAwHJ1t52zklOY/yLwlbKR6Ighf6B7uqGXdYVozTPEdG') );
// true
var_dump( $passwordHasher->CheckPassword('secret', '$2a$08$u2uKfE9igO.Cz0SptWxlXeVi0CQglfl3FdRK3YpbGm1NfF1d.CFPm') );
// true