PHP code example of rancoud / crypt

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

    

rancoud / crypt example snippets


composer 

use Rancoud\Crypt\Crypt;

$password = 'my_password';
$hash = Crypt::hash($password);
$result = Crypt::verify($password, $hash);

// use only Argon2i
Crypt::useArgon2i();

// use only bcrypt
Crypt::useBcrypt();

public static function hash(string $password): string

public static function needsRehash(string $hash): bool

public static function verify(string $password, string $hash): bool

public static function getCurrentAlgo(): string

public static function useArgon2id(): void

public static function useArgon2i(): void

public static function useBcrypt(): void

public static function setOptionArgon2iMemoryCost(int $bytes): void

public static function setOptionArgon2iThreads(int $threads): void

public static function setOptionArgon2iTimeCost(int $time): void

public static function setOptionBcryptCost(int $rounds): void

public static function getOptionsArgon2i(): array

public static function getOptionsBcrypt(): array

public static function getRandomString(int $length = 64, ?string $characters = null): string

public static function getCharactersForRandomString(): string

public static function setCharactersForRandomString(string $characters): void