PHP code example of polarising / bcrypt
1. Go to this page and download the library: Download polarising/bcrypt library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
polarising / bcrypt example snippets
// Require the Composer autoloader.
rypt 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!");
}
bash
# Install Composer
curl -sS https://getcomposer.org/installer | php
bash
php composer.phar