PHP code example of netsilik / peppered-passwords

1. Go to this page and download the library: Download netsilik/peppered-passwords 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/ */

    

netsilik / peppered-passwords example snippets



namespace My\Name\Space;

use Netsilik\Lib\PepperedPasswords;

$pepper = hex2bin(env('PEPPER')); // The binary pepper value, stored as a hexadecimal string

$hasher = new PepperedPasswords($pepper);
if ($hasher->verify($new_plaintext_password, $hash)) { // $hash retrieved from the user's record
    echo 'Password ok.';
} else {
    echo 'Wrong credentials.'; 
}