Dcrypt\Cryptobase::hashNormalize PHP Method

hashNormalize() private static method

This will normalize a hash to a certain length by extending it if too short and truncating it if too long. This ensures that any hash algo will work with any combination of other settings. However, it is probably best to make sure that the keysize and algo size are identical so that the input hash passes through unchanged.
private static hashNormalize ( string $hash, integer $size, string $algo ) : string
$hash string Hash to be normalized
$size integer Size of the desired output hash, in bytes
$algo string Hashing algorithm to use for internal operations
return string
    private static function hashNormalize($hash, $size, $algo)
    {
        // Extend hash if too short
        while (Str::strlen($hash) < $size) {
            $hash .= \hash($algo, $hash, true);
        }
        // Truncate to specified number of bytes (if needed) and return
        return Str::substr($hash, 0, $size);
    }