Calculates the hash of the specified data array.
@param array $data
@return string
434806
public static function calculateHashOfArray(array $data): string
    {
        return self::calculateHash((string) json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
    }
540251
public static function buildDeEmojiData(array $data)
    {
        foreach ($data as $key => $value) {
            if (is_array($value)) {
                $data[$key] = self::buildDeEmojiData($value);
            } elseif (is_string($value)) {
                $data[$key] = self::emojiDecode($value);
            } else {
                $data[$key] = $value;
            }
        }
        return $data;
    }
784319
protected static function checksum($data)
    {
        $bit = unpack('n*', $data);
        $sum = array_sum($bit);
        if (mb_orig_strlen($data) % 2) {
            $temp = unpack('C*', $data[mb_orig_strlen($data) - 1]);
            $sum += $temp[1];
        }
        $sum = ($sum >> 16) + ($sum & 0xffff);
        $sum += ($sum >> 16);
        return pack('n*', ~$sum);
    }
795192
public function last($data)
    {
        if ( !is_array($data) && !is_object($data) && !is_null($data) ) {

            if ( !isset($this->cache['L']) ) {

                $hash = md5($data);

                if (empty($this->dict['L'])) {
                    $this->dict['L'] = $hash;
                    $res = false;
                } elseif ($this->dict['L'] !== $hash) {
                    $this->dict['L'] = $hash;
                    $res = true;
                } else {
                    $res = false;
                }

                $this->cache['L'] = $res;
            }

            return $this->cache['L'];
        }

        $this->data = $data;
        $this->branch = 'L';
        $this->vars = array();
        return $this;
    }
412714
public function verifySignature(array $data)
    {
        $signedData = array_intersect_key($data, array_flip(self::$validResponseParams));
        ksort($signedData);

        $queryString = $this->buildQueryString($signedData);
        $signature = base64_encode(hash_hmac('sha1', $queryString, $this->clientSecret, true));

        return hash_equals($signature, $data['h']);
    }
445798
static public function addslashes($data)
	{
	    if(!is_array($data)) return addslashes($data);
	    
	    foreach($data as $key => $val) {
	        $data[$key] = static::addslashes($val);
	    }
	    
	    return $data;
	}
224704
public function computeMac(array $data)
    {
        for ($i = count($data); $i < 19; $i++) {
            $data[$i] = null;
        }

        return strtolower(hash_hmac("sha1", implode('*', array_values($data)), $this->getMacKey()));
    }
1293438
public static function digest(string $data, string $algorithm): Hash {
        $hash = new Hash();
        $hash->setAlgorithm($algorithm);
        $hash->setValue(openssl_digest($data, $algorithm, TRUE));
        return $hash;
    }
560395
protected function asArray($data)
  {
    $array = [];
    
    foreach(get_object_vars((object)$data) as $k => $v){
      if ( is_object($v) ){
        $array[$k] = $this->asArray($v);
      }
      else {
        $array[$k] = $v;
      }
    }
    
    return $array;
  }
793177
protected function extractData(array $data)
    {
        $converted = array();

        foreach ($data as $value) {

            if ($value instanceof Result) {

                $converted[$value->getId()] = $value->getData();
            }
        }

        return $converted;
    }
254067
public function validateHash(array $data)
    {
        $fpHash = isset($data['fp_hash']) ? $data['fp_hash'] : null;

        if (empty($fpHash)) {
            return true;
        }

        $parameters = $this->getParameters();
        $secret = isset($parameters['secret']) ? $parameters['secret'] : '';

        if (empty($secret)) {
            throw new \Exception("Secret key is required!");
        }

        $response = array(
            $data['fp_paidto'],
            $data['fp_paidby'],
            $data['fp_store'],
            $data['fp_amnt'],
            $data['fp_batchnumber'],
            $data['fp_currency'],
            $secret
        );

        $hash = Security::getHash($response);

        if (strcmp($fpHash, $hash) !== 0) {
            throw new \Exception("Invalid response! Secret key is wrong!");
        }

        return true;
    }
1220891
public static function hash( string $algo = 'sha1', string $data = NULL )
    {
        if (!$data){
            $data = microtime().uniqid(mt_rand(),1);
        }
        return hash( $algo, $data );
    }
1283792
protected function asArray($data)
	{
		$array = array();

		if (is_object($data))
		{
			$data = get_object_vars($data);
		}

		foreach ($data as $k => $v)
		{
			if (is_object($v) || is_array($v))
			{
				$array[$k] = $this->asArray($v);
			}
			else
			{
				$array[$k] = $v;
			}
		}

		return $array;
	}
1140948
public function getHash ()
    {
        if ($this->contextHashData['version'] !== $this->version) {
            $this->contextHashData['version'] = $this->version;
            $this->contextHashData['hash'] = md5(json_encode($this->data));
        }
        
        return $this->contextHashData['hash'];
    }
1239851
public function arraySerialize(array $Data)
    {
        $Result = "";
        foreach ($Data as $Value) {
            if ($Result == "") {
                $Result = floor($Value);
            } else {
                $Result = $Result . "," . floor($Value);
            }
        }

        return $Result;
    }
1142678
private function process(array $data) {
    // Group items at first.
    $grouped = [];
    foreach ($data as $locationId => $locationItems) {
      foreach ($locationItems as $item) {
        $grouped[$locationId][$item['class_id']][] = $item;
      }
    }

    $hashes = [];
    $processed = [];

    foreach ($grouped as $locationId => $locationData) {
      foreach ($locationData as $classId => $classData) {
        $hashes[$locationId][$classId] = (string) md5(serialize($classData));

        foreach ($classData as $class) {
          $this->cleanUpTitle($class);
          $class['location_id'] = $locationId;
          $processed[$locationId][$classId][] = $class;
        }
      }
    }

    $this->hashes = $hashes;

    return $processed;
  }
693743
public static function getKeyDataFromString(string $data): string
    {
        $versionTag = Binary::safeSubstr($data, 0, Halite::VERSION_TAG_LEN);
        $keyData = Binary::safeSubstr(
            $data,
            Halite::VERSION_TAG_LEN,
            -\SODIUM_CRYPTO_GENERICHASH_BYTES_MAX
        );
        $checksum = Binary::safeSubstr(
            $data,
            -\SODIUM_CRYPTO_GENERICHASH_BYTES_MAX,
            \SODIUM_CRYPTO_GENERICHASH_BYTES_MAX
        );
        $calc = \sodium_crypto_generichash(
            $versionTag . $keyData,
            '',
            \SODIUM_CRYPTO_GENERICHASH_BYTES_MAX
        );
        if (!\hash_equals($calc, $checksum)) {
            // @codeCoverageIgnoreStart
            throw new InvalidKey(
                'Checksum validation fail'
            );
            // @codeCoverageIgnoreEnd
        }
        \sodium_memzero($data);
        \sodium_memzero($versionTag);
        \sodium_memzero($calc);
        \sodium_memzero($checksum);
        return $keyData;
    }