PHP code example of luisinder / blowfish-lib

1. Go to this page and download the library: Download luisinder/blowfish-lib 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/ */

    

luisinder / blowfish-lib example snippets






$bf = new BlowFish(12); // cost factor 12

$hash = $bf->hashPassword('My$ecretP@ss');

if ($bf->verifyPassword('My$ecretP@ss', $hash)) {
	echo "Password valid"; 
} else {
	echo "Invalid password";
}

$bf->crypt_blowfish($password);
$bf->checkPassword($plain, $hash);

$bf->hashPassword($password);
$bf->verifyPassword($plain, $hash);

$bf = new BlowFish(10);
$hash = $bf->hashPassword('secret');

// Later increase cost
$bfStronger = new BlowFish(12);
if ($bfStronger->needsRehash($hash)) {
	$hash = $bfStronger->hashPassword('secret');
}