polarising / bcrypt
Customized Bcrypt for PHP
Installs: 44 825
Dependents: 2
Suggesters: 0
Security: 0
Stars: 3
Watchers: 2
Forks: 2
Open Issues: 0
Requires
- php: >=5.3.7
Requires (Dev)
- phpunit/phpunit: ~4.0|~5.0
This package is auto-updated.
Last update: 2024-12-11 20:18:47 UTC
README
========
Instead of using PHP hash password API, encrypt plain text by using Bcrypt algorithm, and make sure it's compatible with Bcrypt in other programming languages, like Java, python.
Installing Bcrypt
The recommended way to install Bcrypt is through Composer.
# Install Composer curl -sS https://getcomposer.org/installer | php
Next, run the Composer command to install the latest stable version of Bcrypt:
php composer.phar require polarising/bcrypt
After installing, you need to require Composer's autoloader:
require 'vendor/autoload.php';
You can then later update Bcrypt using composer:
composer.phar update
Quick Examples
Encrypt Plaintext, Verify Plaintext and Ciphertext
<?php // Require the Composer autoloader. require 'vendor/autoload.php'; use Bcrypt\Bcrypt; // Instantiate an Bcrypt instance. $bcrypt = new Bcrypt(); //Encrypt the plaintext $plaintext = 'password'; //Set the Bcrypt Version, default is '2y' $bcrypt_version = '2a'; $ciphertext = $bcrypt->encrypt($plaintext,$bcrypt_version); print_r("\n Plaintext:".$plaintext); print_r("\n Ciphertext:".$ciphertext); //Verify the plaintext and ciphertext if($bcrypt->verify($plaintext, $ciphertext)){ print_r("\n Password verified!"); }else{ print_r("\n Password not match!"); }