public static function pbkdf2(
        string $algorithm,
        string $password,
        string $salt,
        int $count,
        int $length,
        bool $raw = false
    ) {
        $algorithm = \strtolower($algorithm);
        // Whitelist, or we could end up with people using CRC32.
        if (!isset(self::$hashList[$algorithm])) {
            throw new CryptoException('Algorithm is not a secure cryptographic hash function.');
        }

        if ($count <= 0 || $length <= 0) {
            throw new CryptoException('Invalid PBKDF2 parameters.');
        }

        // The output length is in NIBBLES (4-bits) if $raw_output is false!
        if (!$raw) {
            $length *= 2;
        }

        return \hash_pbkdf2($algorithm, $password, $salt, $count, $length, $raw);
    }