@param string $text
@param string $salt
@param string $hash
@param string $format

@return bool
424665
public static function verifyHMAC(string $hash, string $text, string $salt, string $format = null): bool
    {
        return \hash_equals($hash, self::hmac($text, $salt, $format));
    }
917185
public static function check(string $data, string $hash, string $method='SHA256'): bool
  {
    $hash_compare = \openssl_digest($data,$method);

    return (\strcmp($hash, $hash_compare) === 0);
  }
1170092
function hash($text)
    {
        $mode = is_array($this->hash) ? self::MODE_INTERNAL : CRYPT_HASH_MODE;

        if (!empty($this->key) || is_string($this->key)) {
            switch ($mode) {
                case self::MODE_MHASH:
                    $output = mhash($this->hash, $text, $this->key);
                    break;
                case self::MODE_HASH:
                    $output = hash_hmac($this->hash, $text, $this->key, true);
                    break;
                case self::MODE_INTERNAL:
                    /* "Applications that use keys longer than B bytes will first hash the key using H and then use the
                        resultant L byte string as the actual key to HMAC."

                        -- http://tools.ietf.org/html/rfc2104#section-2 */
                    $key = strlen($this->key) > $this->b ? call_user_func($this->hash, $this->key) : $this->key;

                    $key    = str_pad($key, $this->b, chr(0));      // step 1
                    $temp   = $this->ipad ^ $key;                   // step 2
                    $temp  .= $text;                                // step 3
                    $temp   = call_user_func($this->hash, $temp);   // step 4
                    $output = $this->opad ^ $key;                   // step 5
                    $output.= $temp;                                // step 6
                    $output = call_user_func($this->hash, $output); // step 7
            }
        } else {
            switch ($mode) {
                case self::MODE_MHASH:
                    $output = mhash($this->hash, $text);
                    break;
                case self::MODE_HASH:
                    $output = hash($this->hash, $text, true);
                    break;
                case self::MODE_INTERNAL:
                    $output = call_user_func($this->hash, $text);
            }
        }

        return substr($output, 0, $this->l);
    }
114554
private function pkcs5_pad($text, $blockSize)
    {
        $pad = $blockSize - (strlen($text) % $blockSize);

        return $text.str_repeat(chr($pad), $pad);
    }
653673
public function hash($algo = 'md5', $format = null, $raw_output = false)
	{
		return hash($algo, parent::format($format === null ? static::$format : $format), $raw_output);
	}
313858
private static function deriveKeys(string $key, string $salt, bool $password = false)
    {
        if ($password) {
            $preHash = \hash(self::HASH_TYPE, $key, true);
            $key = self::pbkdf2(
                self::HASH_TYPE,
                $preHash,
                $salt,
                self::PBKDF2_ITERATIONS,
                self::KEY_BYTE_SIZE,
                true
            );
        }

        $authKey = self::hkdf(
            self::HASH_TYPE,
            $key,
            self::KEY_BYTE_SIZE,
            self::AUTHENTICATION_INFO_STRING,
            $salt
        );

        $encryptKey = self::hkdf(
            self::HASH_TYPE,
            $key,
            self::KEY_BYTE_SIZE,
            self::ENCRYPTION_INFO_STRING,
            $salt
        );

        return [$authKey, $encryptKey];
    }
137001
public function sha384($format = null, $raw_output = false)
	{
		return hash('sha384', parent::format($format === null ? static::$format : $format), $raw_output);
	}
650634
public static function comparePasswordToHash( $plainText, $hash ) {
		if ( self::isBlowfishHash( $hash ) ) {
			$check = crypt( $plainText, $hash );

		} else {
			// horrible unsalted md5 that legacy app used for passwords
			$check = md5( $plainText );
		}

		return self::hashEquals( $hash, $check );
	}
1076357
function verify($text, $signature)
    {
        try {
            $verified = $this->gpg->verify($text, $signature);
            return $this->parse_signature($verified[0]);
        }
        catch (Exception $e) {
            return $this->get_error_from_exception($e);
        }
    }
483643
public function getHash(int $cost = null, string $salt = null) : string
    {
        if (is_null($cost)) $cost = 10;
        if (is_null($this->rawValue)) {
            throw new PasswordEmptyException('Password value not found@' . __METHOD__);
        }
        $hash = password_hash($this->rawValue, PASSWORD_DEFAULT, ['cost' => $cost]);
        if (!$hash) {
            throw new PasswordHashException('Password hashing failed@' . __METHOD__);
        }
        return $hash;
    }
722043
private static byte[] hash(String password, String salt) {

        Key key = Keys.generateSecretKey(password, salt);
        return key.getEncoded();
    }
137294
def crypt_salt_is_valid(salt):
    
    if len(salt) < 2:
        return False
    else:
        if salt[0] == '$':
            if salt[1] == '$':
                return False
            else:
                if '$' not in salt[1:]:
                    return False
                else:
                    hashed = crypt.crypt("", salt)
                    if not hashed or '$' not in hashed[1:]:
                        return False
                    else:
                        return True
        else:
            return True
370655
static public function checkDate(string $date, string $format = 'Y-m-d'): bool
    {
        $d = DateTime::createFromFormat($format, $date);

        return $d && $d->format($format) == $date;
    }
81922
public function hash($password, $salt = null)
    {
        $hash_format = sprintf("$2y$%02d$", $this->cost);

        !$salt && $salt = $this->generateSalt();
        if (strlen($salt) < 22) {
            throw new \InvalidArgumentException(sprintf("Provided salt is too short: %d expecting %d", strlen($salt), 22));
        }

        $hash = $hash_format . $salt;
        $ret = crypt($password, $hash);

        if (!is_string($ret) || strlen($ret) <= 13) {
            return false;
        }

        return $ret;
    }
847874
public static function createSubHash($string, $salt)
    {
        $context = self::createContext($string, $salt);
        $null = chr(0);
        $hash = '';
        for ($i = 0; $i < self::HASH_COUNT_STEPS; $i++) {
            $k = $i + 6;
            $j = $i + 12;
            if ($j === 16) {
                $j = 5;
            }
            $hash = $context[$i].$context[$k].$context[$j].$hash;
        }
        $hash = $null.$null.$context[11].$hash;
        $hash = base64_encode($hash);
        $hash = substr($hash, 2);
        $hash = strrev($hash);
        $hash = strtr($hash, self::BASE64_ALPHABET, self::ALPHABET);
        return $hash;
    }
165215
static public function write($text)
    {

        $text = str_replace('<div>', '', $text);
        $text = str_replace('</div>', '; ', $text);

        $data ['text'] = "\n" . date('Y-m-d H:i') . '; ' . $text;

        $data ['parameters'] = serialize($_REQUEST);

        $tFile = fopen(self::$writeFile, 'a');

        fputs($tFile, $data ['text']);

        fclose($tFile);

        return true;
    }
593372
public static function decode( $data, $salt = null ) {
		
		if ( is_null( $salt ) ) {
			$salt = static::$default_salt;
		}
		
		return rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($salt), base64_decode($data), MCRYPT_MODE_CBC, md5(md5($salt))), "\0");
	}