Hash Key 檢查.

@author		https://www.ecpay.com.tw
@category	Validate
@version		1.0.1012
967676
private function ValidateHashKey()
        {
            $Name = 'HashKey'; // 參數名稱
            $Value = $this->HashKey; // 參數內容
            $AllowEmpty = false; // 是否允許空值

            if (empty($Value)) {
                // 是否允許空值
                $this->IsAllowEmpty($Name, $AllowEmpty);
            }
        }
342366
public function calculateHash()
    {
        $str =  $this->data['ECM_TRANS_ID'] .
                $this->data['ECM_TRANS_DATE'] .
                $this->request->getPurse() .
                $this->data['ECM_PAYER_ID'] .
                $this->data['ECM_ITEM_COST'] .
                $this->data['ECM_QTY'] .
                $this->request->getSecret();

        return md5($str);
    }
66524
public static String hashKey(String key) {
        try {
            MessageDigest md = MessageDigest.getInstance("SHA1");
            md.update(key.getBytes(StandardCharsets.UTF_8));
            md.update(MAGIC);
            return new String(B64Code.encode(md.digest()));
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
1213932
public function hashCode()
    {
        $validPk = null !== $this->getRoleId() &&
            null !== $this->getPermissionId();

        $validPrimaryKeyFKs = 2;
        $primaryKeyFKs = [];

        //relation role_permission_fk_1ff99e to table role
        if ($this->aRole && $hash = spl_object_hash($this->aRole)) {
            $primaryKeyFKs[] = $hash;
        } else {
            $validPrimaryKeyFKs = false;
        }

        //relation role_permission_fk_2b894c to table permission
        if ($this->aPermission && $hash = spl_object_hash($this->aPermission)) {
            $primaryKeyFKs[] = $hash;
        } else {
            $validPrimaryKeyFKs = false;
        }

        if ($validPk) {
            return crc32(json_encode($this->getPrimaryKey(), JSON_UNESCAPED_UNICODE));
        } elseif ($validPrimaryKeyFKs) {
            return crc32(json_encode($primaryKeyFKs, JSON_UNESCAPED_UNICODE));
        }

        return spl_object_hash($this);
    }
725250
protected function hashKey($key)
    {
        if ($key instanceof \DateTime) {
            return md5('_' . $key->format('c'));
        } elseif (is_object($key)) {
            return spl_object_hash($key);
        } elseif (false === $key) {
            return md5('_false');
        } elseif (true === $key) {
            return md5('_true');
        } elseif (null === $key) {
            return md5('_null');
        } elseif (is_array($key)) {
            array_multisort($key);
            return md5(json_encode($key));
        } elseif (is_int($key)) {
            return md5('_' . $key);
        } elseif (is_float($key)) {
            return md5('_' . $key);
        } else {
            return md5(strval($key));
        }
    }
617506
public function hasKey()
    {
        $this->failIf(!array_key_exists($this->data[1], $this->data[0]));

        return $this->data[0][$this->data[1]];
    }
252952
protected function generateCacheKey()
    {
        $name = $this->connection->getName();

        $data = $name.$this->toSql().serialize($this->getBindings());

        return hash(static::HASH_ALGO, $data);
    }
763304
public function verifyHash() {
		$this->ensureInput();
		if(empty($this->input['hash']))
			throw new WebHookHandlerException('No hash provided in input payload', WebHookHandlerException::NO_INPUT_HASH);
		
		if($this->input['payloadEncrypted']) {
			if(!$this->payloadJSONString && !$this->getPayload()) return false;
		} else {
			if(!$this->payloadJSONString) $this->payloadJSONString = json_encode($this->input['payload']);
		}
		
		$webHookSalt = substr($this->input['hash'], 0, self::SALT_LENGTH);
		return $this->input['hash'] === $webHookSalt.hash(self::HASH_METHOD, $webHookSalt.$this->secret.$this->payloadJSONString);
	}
922090
public function hashCode()
    {
        $h = crc32(serialize($this->value)) ^ crc32($this->comparison);

        if ($this->table !== null) {
            $h ^= crc32($this->table);
        }

        if ($this->column !== null) {
            $h ^= crc32($this->column);
        }

        foreach ($this->clauses as $clause) {
            // TODO: I KNOW there is a php incompatibility with the following line
            // but I don't remember what it is, someone care to look it up and
            // replace it if it doesn't bother us?
            // $clause->appendPsTo($sb='',$params=array());
            $sb = '';
            $params = array();
            $clause->appendPsTo($sb, $params);
            $h ^= crc32(serialize(array($sb, $params)));
            unset ($sb, $params);
        }

        return $h;
    }
464214
def hash_key(self, key):
        
        for i, destination_key in enumerate(self._dict):
            if key < destination_key:
                return destination_key

        return key
476172
protected function _hashKey( $key )
    {
        if ( null !== $this->_keyHashCallback && is_callable( $this->_keyHashCallback ) )
        {
            $_arguments = func_get_args();

            return call_user_func_array( $this->_keyHashCallback, $_arguments );
        }

        return $key;
    }
1098760
function hashKey(requestorId, taskId) {
  var sha       = crypto.createHash('sha512');
  sha.update(requestorId);
  sha.update(taskId);

  return sha.digest('hex');
}
1030155
public function setKey($key)
    {
        $this->hash = null;

        if (empty($key)) {
            $this->key = null;
            return;
        }

        $this->key = (string) $key;
        $this->hash = $this->makeHash($key);
    }
729247
public function hashCode()
    {
        $validPk = null !== $this->getCategoryId() &&
            null !== $this->getMediaId();

        $validPrimaryKeyFKs = 2;
        $primaryKeyFKs = [];

        //relation c2m_fk_904832 to table category
        if ($this->aCategory && $hash = spl_object_hash($this->aCategory)) {
            $primaryKeyFKs[] = $hash;
        } else {
            $validPrimaryKeyFKs = false;
        }

        //relation c2m_fk_32dfd1 to table media
        if ($this->aMedia && $hash = spl_object_hash($this->aMedia)) {
            $primaryKeyFKs[] = $hash;
        } else {
            $validPrimaryKeyFKs = false;
        }

        if ($validPk) {
            return crc32(json_encode($this->getPrimaryKey(), JSON_UNESCAPED_UNICODE));
        } elseif ($validPrimaryKeyFKs) {
            return crc32(json_encode($primaryKeyFKs, JSON_UNESCAPED_UNICODE));
        }

        return spl_object_hash($this);
    }
198290
public static function hash_key($key, cache_definition $definition) {
        if ($definition->uses_simple_keys()) {
            if (debugging() && preg_match('#[^a-zA-Z0-9_]#', $key)) {
                throw new coding_exception('Cache definition '.$definition->get_id().' requires simple keys. Invalid key provided.', $key);
            }
            // We put the key first so that we can be sure the start of the key changes.
            return (string)$key . '-' . $definition->generate_single_key_prefix();
        }
        $key = $definition->generate_single_key_prefix() . '-' . $key;
        return sha1($key);
    }
371088
private function key_to_hash($key)
    {
        if (null === $key) {
            $hash = 'null';

        } else if (is_int($key)) {
            $hash = $key;

        } else if (is_float($key)) {
            $hash = "f_$key";

        } else if (is_bool($key)) {
            $hash = "b_$key";

        } else if (is_string($key)) {
            $hash = "s_$key";

        } else if (is_object($key) || is_callable($key)) {
            $hash = spl_object_hash($key);

        } else if (is_array($key)) {
            $hash = 'a_' . md5(json_encode($key));

        } else if (is_resource($key)) {
            $hash = "r_$key";

        } else {
            throw new \InvalidArgumentException(sprintf(
                'Unsupported key type "%s"',
                gettype($key)
            ));
        }

        $this->map_hash_to_key[$hash] = $key;
        return $hash;
     }
678832
function jenkinsHash(key) {
      var hash, i;
      for(hash = i = 0; i < key.length; ++i) {
        hash += key.charCodeAt(i);
        hash += (hash << 10);
        hash ^= (hash >> 6);
      }
      hash += (hash << 3);
      hash ^= (hash >> 11);
      hash += (hash << 15);
      return hash;
    }