Hi() call, which is essentially PBKDF2 (RFC-2898) with HMAC-H() as the pseudorandom function.

@param string $str The string to hash.
@param string $hash The hash value.
@param int $i The iteration count.
@access private
488001
private function hi($str, $salt, $i)
    {
        $int1 = "\0\0\0\1";
        $ui = call_user_func($this->hmac, $str, $salt . $int1, true);
        $result = $ui;
        for ($k = 1; $k < $i; $k++)
        {
            $ui = call_user_func($this->hmac, $str, $ui, true);
            $result = $result ^ $ui;
        }
        return $result;
    }
201350
function setHash($hash)
    {
        $this->hashParam = $hash = strtolower($hash);
        switch ($hash) {
            case 'md5-96':
            case 'sha1-96':
            case 'sha256-96':
            case 'sha512-96':
                $hash = substr($hash, 0, -3);
                $this->l = 12; // 96 / 8 = 12
                break;
            case 'md2':
            case 'md5':
                $this->l = 16;
                break;
            case 'sha1':
                $this->l = 20;
                break;
            case 'sha256':
                $this->l = 32;
                break;
            case 'sha384':
                $this->l = 48;
                break;
            case 'sha512':
                $this->l = 64;
        }

        switch ($hash) {
            case 'md2':
                $mode = CRYPT_HASH_MODE == self::MODE_HASH && in_array('md2', hash_algos()) ?
                    self::MODE_HASH : self::MODE_INTERNAL;
                break;
            case 'sha384':
            case 'sha512':
                $mode = CRYPT_HASH_MODE == self::MODE_MHASH ? self::MODE_INTERNAL : CRYPT_HASH_MODE;
                break;
            default:
                $mode = CRYPT_HASH_MODE;
        }

        switch ($mode) {
            case self::MODE_MHASH:
                switch ($hash) {
                    case 'md5':
                        $this->hash = MHASH_MD5;
                        break;
                    case 'sha256':
                        $this->hash = MHASH_SHA256;
                        break;
                    case 'sha1':
                    default:
                        $this->hash = MHASH_SHA1;
                }
                return;
            case self::MODE_HASH:
                switch ($hash) {
                    case 'md5':
                        $this->hash = 'md5';
                        return;
                    case 'md2':
                    case 'sha256':
                    case 'sha384':
                    case 'sha512':
                        $this->hash = $hash;
                        return;
                    case 'sha1':
                    default:
                        $this->hash = 'sha1';
                }
                return;
        }

        switch ($hash) {
            case 'md2':
                $this->b = 16;
                $this->hash = array($this, '_md2');
                break;
            case 'md5':
                $this->b = 64;
                $this->hash = array($this, '_md5');
                break;
            case 'sha256':
                $this->b = 64;
                $this->hash = array($this, '_sha256');
                break;
            case 'sha384':
            case 'sha512':
                $this->b = 128;
                $this->hash = array($this, '_sha512');
                break;
            case 'sha1':
            default:
                $this->b = 64;
                $this->hash = array($this, '_sha1');
        }

        $this->ipad = str_repeat(chr(0x36), $this->b);
        $this->opad = str_repeat(chr(0x5C), $this->b);
    }
629277
public function setHash($hash)
    {
      if(!is_string($hash) || strlen(trim($hash)) == 0)
        throw new InvalidArgumentException(__METHOD__ . '; Invalid hash, must be a non empty string');

      $this->hash = $hash;
    }
125807
public static function hash($str, $algo = self::MD5_HASH, $hmacKey = '', $rawOuput = false, $salt = null, $passwordAlgo = PASSWORD_DEFAULT, $passwordOptions = [])
    {
        if ($hmacKey && in_array($algo, [self::MD5_HASH, self::SHA1_HASH])) {
            return hash_hmac($algo, $str, $hmacKey, $rawOuput);
        }

        switch ($algo) {
        case self::MD5_HASH:
            $hashCode = md5($str, $rawOuput);
            break;
        case self::SHA1_HASH:
            $hashCode = sha1($str, $rawOuput);
            break;
        case self::CRYPT_HASH:
            $hashCode = crypt($str, $salt);
            break;
        case self::PASSWORD_HASH:
            $hashCode = password_hash($str, $passwordAlgo, $passwordOptions);
            break;
        default:
            $hashCode = md5($str, $rawOuput);
        }

        return $hashCode;
    }
386112
protected function loadPyStringHash(array $hash, $line = 0)
    {
        $line = isset($hash['line']) ? $hash['line'] : $line;

        $strings = array();
        foreach (explode("\n", $hash['text']) as $string) {
            $strings[] = $string;
        }

        return new PyStringNode($strings, $line);
    }
633526
public function pbkdf2($p, $s, $c, $dkLen, $a = 'sha256') {
    $hLen = strlen(hash($a, null, true)); /* Hash length. */
    $l    = ceil($dkLen / $hLen);         /* Length in blocks of derived key. */
    $dk   = '';                           /* Derived key. */

    /* Step 1. Check dkLen. */
    if($dkLen > (2^32-1) * $hLen) {
      throw new \phpSec\Exception\GeneralSecurityException('Derived key too long');
      return false;
    }

    for ($block = 1; $block<=$l; $block ++) {
      /* Initial hash for this block. */
      $ib = $b = hash_hmac($a, $s . pack('N', $block), $p, true);
      /* Do block iterations. */
      for ($i = 1; $i<$c; $i ++) {
        /* XOR iteration. */
        $ib ^= ($b = hash_hmac($a, $b, $p, true));
      }
      /* Append iterated block. */
      $dk .= $ib;
    }
    /* Returned derived key. */
    return substr($dk, 0, $dkLen);
  }
510918
public static function decrypt($string, $hash = false)
    {
        // if has $string or invalid no value or not as string stop here
        if (!is_string($string) || strlen(trim($string)) < 4
            || (strlen($string) > 10 ? (substr($string, 10, 5) !== '_mCb=') : (substr($string, 2, 5) !== '_mCb='))
        ) {

            // check if mCrypt is not loaded and decrypt using alt decrypt
            if (is_string($string)
                && strlen(trim($string)) > 3
                && (strlen($string) > 10 ? (substr($string, 10, 5) === '_aCb=') : (substr($string, 2, 5) === '_aCb='))
            ) {
                return static::altDecrypt($string, $hash);
            }

            return null;
        }

        if (! extension_loaded('mCrypt')) {
            return null;
        }

        /**
         * Replace Injection 3 characters sign
         */
        $string = (strlen($string) > 10
            ? substr_replace($string, '', 10, 5)
            : substr_replace($string, '', 2, 5)
        );
        // this is base64 safe encoded?
        if (preg_match('/[^a-z0-9\+\/\=\-\_]/i', $string)) {
            return null;
        }

        /**
         * ------------------------------------
         * Safe Sanitized hash
         * ------------------------------------
         */
        (is_null($hash) || $hash === false) && $hash = '';
        // safe is use array or object as hash
        $hash        = Util::maybeSerialize($hash);

        /**
         * ------------------------------------
         * Set Key
         * ------------------------------------
         */
        $key         = pack('H*', sha1(sha256::hash($hash)));
        /**
         * pad to 24 length
         * on PHP 5.5 + need keylength 16, 24 or 32
         */
        $key         = str_pad($key, 24, "\0", STR_PAD_RIGHT);

        /**
         * Doing decode of input encryption
         */
        $crypted_text   = Util::safeBase64Decode($string);
        
        /**
         * ------------------------------------
         * Doing deryption
         * ------------------------------------
         */
        $iv_size     = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
        $iv          = mcrypt_create_iv($iv_size, MCRYPT_RAND);
        $decrypted_text = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $crypted_text, MCRYPT_MODE_ECB, $iv);

        /**
         * unserialize the string, that before has been serialize
         */
        $decrypted_text = Util::maybeUnSerialize(trim($decrypted_text));

        /**
         * Check if value is array
         */
        if (is_array($decrypted_text) && array_key_exists('mcb', $decrypted_text)) {
            unset($string, $key, $iv);
            return $decrypted_text['mcb'];
        }

        // freed the memory
        unset($decrypted_text, $crypted_text, $string, $key, $iv);

        return null;
    }
179319
public static function stringIdx($str, $idx)
    {
        // FIXME: Make the const-time hack below work for all integer sizes, or
        // check it properly
        $l = mb_orig_strlen($str);
        if ($l > 65535 || $idx > $l) {
            return false;
        }
        $r = 0;
        for ($i = 0; $i < $l; ++$i) {
            $x = $i ^ $idx;
            $mask = (((($x | ($x >> 16)) & 0xFFFF) + 0xFFFF) >> 16) - 1;
            $r |= ord($str[$i]) & $mask;
        }
        return chr($r);
    }
415511
function hashCode(str) {
    var hash = 0xdeadbeef;
    for (var i = str.length; i >= 0; --i) {
        hash = (hash * 33) ^ str.charCodeAt(--i);
    }
    // turn to unsigned 32bit int
    return hash >>> 0;
}
490668
private static function decryptStandard(
        $hash,
        $crypt_text,
        $method,
        $iv
    ) {
        if (substr($iv, 0, strlen($method)) !== $method) {
            return null;
        }

        /**
         * ------------------------------------
         * Doing convert encrypted string
         * ------------------------------------
         */
        /**
         * Doing decode of input encryption
         */
        $crypt_text = self::safeBase64Decode($crypt_text);
        $enc_arr  = str_split($crypt_text);
        $add = 0;
        $div = strlen($crypt_text) / strlen($hash);
        $new_pass = '';
        while ($add <= $div) {
            $new_pass .= $hash;
            $add++;
        }
        $pass_arr = str_split($new_pass);
        $ascii ='';
        foreach ($enc_arr as $key => $asc) {
            $pass_int = ord($pass_arr[$key]);
            $enc_int = ord($asc);
            $str_int = $enc_int - $pass_int;
            $ascii .= chr(($str_int-strlen($crypt_text)));
        }

        /* --------------------------------
         * reversing
         * ------------------------------ */
        // unpack
        $unpack     = unpack('a*', trim($ascii));

        /**
         * if empty return here
         */
        if (empty($unpack)) {
            return null;
        }

        // implode the unpacking array
        $unpack = implode('', (array) $unpack);
        $iv     = substr($iv, strlen($method));
        if (strlen($hash) < strlen($unpack)) {
            $sub_iv = substr($unpack, strlen($hash), strlen($iv));
        } else {
            $sub_iv = substr($unpack, -strlen($iv));
        }
        if ($sub_iv !== $iv) {
            return null;
        }
        $crypt_text = substr_replace($unpack, '', strlen($hash), strlen($iv));
        return self::rotate($crypt_text, -(strlen($hash) % 13));
    }
166624
public static function BKDRHash( $str ) {

        $hval = 0;
        $len  = strlen($str);

        /*
         * 4-bytes integer we will directly take
         * its int value as the final hash value.
        */
        $seed = 131;    // 31 131 1313 13131 131313 etc..
        if ( $len <= 11 && is_numeric($str) ) {
            $hval = intval($str);
        } else {
            for ( $i = 0; $i < $len; $i++ ) {
                $hval = (int) ($hval * $seed + (ord($str[$i]) % 127));
            }
        }

        return ($hval & 0x7FFFFFFF);
    }
642052
public static function _decryptRijndael256 ($str, $key, $iv)
	{
		
		// If the string is empty
		
		if (empty ($str))
		{
			return '';
		}
		
		// Open the cypher
		
		$cypher		= mcrypt_module_open ('rijndael-256', '', 'ofb', '');
		
		// Set Key
		
		$key		= substr ($key, 0, mcrypt_enc_get_key_size ($cypher));
		
		// Initialise decryption
		
		mcrypt_generic_init ($cypher, $key, $iv);
		
		// Decrypt String
		
		$decrypted	= mdecrypt_generic ($cypher, $str);
		
		// Terminate encryption hander
		
		mcrypt_generic_deinit ($cypher);
		
		// Close Module
		
		mcrypt_module_close ($cypher);
		
		// Return decrypted string
		
		return $decrypted;
		
	}
1339183
public static boolean is_jhal(String str)
    {

        if (is_vargiya4(str) || is_vargiya3(str) || is_vargiya2(str) || is_vargiya1(str) || is_shar(str) || str.equals("h")) return true;

        return false;
    }
1301355
function hash($text)
    {
        $mode = is_array($this->hash) ? CRYPT_HASH_MODE_INTERNAL : CRYPT_HASH_MODE;

        if (!empty($this->key) || is_string($this->key)) {
            switch ($mode) {
                case CRYPT_HASH_MODE_MHASH:
                    $output = mhash($this->hash, $text, $this->key);
                    break;
                case CRYPT_HASH_MODE_HASH:
                    $output = hash_hmac($this->hash, $text, $this->key, true);
                    break;
                case CRYPT_HASH_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 CRYPT_HASH_MODE_MHASH:
                    $output = mhash($this->hash, $text);
                    break;
                case CRYPT_HASH_MODE_HASH:
                    $output = hash($this->hash, $text, true);
                    break;
                case CRYPT_HASH_MODE_INTERNAL:
                    $output = call_user_func($this->hash, $text);
            }
        }

        return substr($output, 0, $this->l);
    }
86152
public static function murmurhash($str, int $seed = 0, $isInt = false, $version = 3)
    {
        if ($version != 3) {
            throw new ParamException('Murmurhash' . $version . ' not supported');
        }

        return $isInt ? Murmur::hash3_int($str, $seed) : Murmur::hash3($str, $seed);
    }
132712
public function encrypt($str = null, $key = null)
    {
        if (!is_null($key)) {
            $this->setSalt($key);
        }
        srand((double)microtime()*1000000);
        $key_encrypt    = md5(rand(0,32000));
        $count          = 0;
        $tmp            = '';
        for ($ctr=0;$ctr<strlen($str);$ctr++) {
            if ($count==strlen($key_encrypt)) {
                $count=0;
            }
            $tmp.= substr($key_encrypt,$count,1).(substr($str,$ctr,1) ^ substr($key_encrypt,$count,1) );
            $count++;
        }
        return base64_encode(self::getEncryptionKey($tmp));
    }
729991
public static long mixHash(String str) {
		long hash = str.hashCode();
		hash <<= 32;
		hash |= fnvHash(str);
		return hash;
	}