davidkuridza/php-bcrypt-wrapper

dev-master 2013-10-07 05:17 UTC

This package is not auto-updated.

Last update: 2024-04-13 10:56:06 UTC


README

Please use PHP's password hashing functions or password_compat.

PHP bcrypt wrapper

Build Status

PHP bcrypt is a wrapper to simplify the use of bcrypt algorithm in PHP.

Requirements

Installation

Copy Bcrypt/Bcrypt.php to location on the file system where needed.

To test whether Bcrypt works in your environment, you can simply run PHPUnit tests from root directory:

$ phpunit

An Ant build script is provided to simplify setting up the environment in case you would like to contribute. Following targets are available:

$ ant
Buildfile: build.xml

help:
     [echo] Usage: ant [target [target1 [target2] ...]]
     [echo] Targets:
     [echo]   help            print this message
     [echo]   build           setup env
     [echo]   clean           clean up and create artifact directories
     [echo]   tests           run unit tests

Running $ ant build will invoke clean and tests.

Usage

include 'Bcrypt.php';

// hash password before storing it
$hashed = Bcrypt::hash($password);

// check password by comparing it to its hashed value
$check  = Bcrypt::check($password, $hashed);

// use a stronger salt
$salt   = Bcrypt::salt(24); // 2^24 iterations
$hashed = Bcrypt::hash($password, $salt);

Contact

Feel free to contact me via david@kuridza.si or twitter.