Crypt using Argon2id by default with Argon2i and bcrypt in fallback.
composer require rancoud/cryptuseRancoud\Crypt\Crypt;
$password = 'my_password';
$hash = Crypt::hash($password);
$result = Crypt::verify($password, $hash);
// use only Argon2i
Crypt::useArgon2i();
// use only bcrypt
Crypt::useBcrypt();Hashs the password according to the selected algorithm.
publicstaticfunction hash(string$password): stringChecks whether the hash needs to be rehash to match the selected algorithm and options.
publicstaticfunction needsRehash(string$hash): boolChecks if password and hash match.
publicstaticfunction verify(string$password, string$hash): boolReturns current algorithm.
Possible values are argon2id, argon2i or 2y.
publicstaticfunction getCurrentAlgo(): stringSets the algorithm to argon2id.
publicstaticfunction useArgon2id(): voidSets the algorithm to argon2i.
publicstaticfunction useArgon2i(): voidSets the algorithm to 2y (bcrypt).
publicstaticfunction useBcrypt(): voidSets memory cost for argon2id and argon2i.
Must be equal or greater than 8.
publicstaticfunction setOptionArgon2iMemoryCost(int$bytes): voidSets number of threads for argon2id and argon2i.
Must be equal or greater than 1.
publicstaticfunction setOptionArgon2iThreads(int$threads): voidSets time cost for argon2id and argon2i.
Must be equal or greater than 1.
publicstaticfunction setOptionArgon2iTimeCost(int$time): voidSets rounds cost for 2y (bcrypt).
Must be between 4 and 31.
publicstaticfunction setOptionBcryptCost(int$rounds): voidReturns options for argon2id and argon2i.
publicstaticfunction getOptionsArgon2i(): arrayReturns options for 2y (bcrypt).
publicstaticfunction getOptionsBcrypt(): arrayReturns a fixed-size string containing random characters from the preselection.
The default character pool is !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_``abcdefghijklmnopqrstuvwxyz{|}~.
publicstaticfunction getRandomString(int$length = 64, ?string$characters = null): stringReturns the character pool.
publicstaticfunction getCharactersForRandomString(): stringSets the character pool.
publicstaticfunction setCharactersForRandomString(string$characters): voidcomposer ci for php-cs-fixer and phpunit and coveragecomposer lint for php-cs-fixercomposer test for phpunit and coverage