PHP code example of crutch / hash-native

1. Go to this page and download the library: Download crutch/hash-native 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/ */

    

crutch / hash-native example snippets




$hasher = new \Crutch\NativeHash\BcryptHash(10); // one argument cost
// or
$hasher = new \Crutch\NativeHash\Argon2IHash(65536, 4, 1); // arguments: memoryCost, timeCost, threads
// or
$hasher = new \Crutch\NativeHash\Argon2IdHash(65536, 4, 1); // arguments: memoryCost, timeCost, threads

$value = 'password';
$hash = $hasher->hash($value);
var_dump($hasher->verify($hash, $value)); // true
var_dump($hasher->isNeedRehash($hash)); // false