@param string $data

@return string
@throws UnsupportedHashAlgorithmException
325141
protected function hash($data)
    {
        switch (strtoupper($this->algorithm)) {
            case 'HMAC-SHA1':
                return hash_hmac('sha1', $data, $this->getSigningKey(), true);

            default:
                throw new UnsupportedHashAlgorithmException(
                    'Unsupported hashing algorithm (' . $this->algorithm . ') used.'
                );
        }
    }
1112854
private function hasher($data)
        {
            $key = $this->privateKey;
            if(strlen($key) > 64)
                $key = pack('H40', sha1($key));
            if(strlen($key) < 64)
                $key = str_pad($key, 64, chr(0));
            $ipad = (substr($key, 0, 64) ^ str_repeat(chr(0x36), 64));
            $opad = (substr($key, 0, 64) ^ str_repeat(chr(0x5C), 64));
            return sha1($opad . pack('H40', sha1($ipad . $data)));
        }
28152
public function add(string $data): string
    {
        $n = $this->_blocksize - strlen($data) % $this->_blocksize;
        return $data . str_repeat(chr($n), $n);
    }
1371219
public static function decrypt($data) : string {
      $crypter = new Crypter();

      return $crypter->decrypt($data, self::getAppKey());
    }
636768
private function generateSignature($data)
    {
        return base64_encode(
            hash_hmac('sha512',
                $this->getMerchantId() . $data . $this->getMerchantId(),
                $this->getPrivateKey())
        );
    }
375979
public function format($data)
    {
        foreach ($this->rules as $oldKey => $newKey) {
            if ($this->isRegex($oldKey)) {
                $this->remapRecursively($data, $oldKey, $newKey);
            } else {
                $this->remap($data, $oldKey, $newKey);
            }
        }

        $data->unsetNull();

        return $data;
    }
5591
public static function getHeaders(string $data): string
    {
        $pos = strpos($data, "\r\n\r\n");

        return $pos === false ? '' : substr($data, 0, $pos);
    }
289559
public function encode($data): string
    {
        $encoded = \json_encode($data, \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE);
        if (\json_last_error() !== JSON_ERROR_NONE) {
            throw new EncodingException(\json_last_error_msg());
        }
        return $encoded;
    }
1107482
public function encode($data)
    {
        // loop over params, look for closure
        if (
            // not a server exception
            !($data instanceof \Plinker\Core\Exception\Server) &&
            // params should be set & array
            isset($data['params']) && is_array($data['params'])) {
            foreach ($data['params'] as $key => $param) {
                if (is_object($param) && ($param instanceof \Closure)) {
                    $data['params'][$key] = new SerializableClosure($param);
                }
            }
        }
        
        $data = serialize($data);

        return [
            "data"  => $this->encrypt($data, $this->config["secret"]),
            "token" => hash_hmac(
                "sha256",
                $data,
                $this->config["secret"]
            )
        ];
    }
1191500
public function makeHashable(Data $data): ?HashableFormat
    {
        if (!$data->isHashable()) {
            return null;
        }

        return HashableFormat::make($data);
    }
874439
public static function encode($data)
    {
        if (!is_string($data)) {
            throw new InvalidArgumentException('data must be string');
        }

        $encodedData = parent::encode($data);

        // URL safe replacement and remove padding
        return rtrim(strtr($encodedData, '+/', '-_'), '=');
    }
241858
public function encode( $data )
    {
        //skip  if external resource
        if (filter_var( $data, FILTER_VALIDATE_URL )) {
            return $data;
        }

        if ($data instanceof MediaAsset) {
            $mediaSource = $data->getMediaSource();
            $data = $data->getMediaIdentifier();

            if ($mediaSource instanceof HttpSource) {
                return $data;
            }

            if ($mediaSource instanceof MediaSource) {
                $fileInfo = $mediaSource->getFileInfo($data);
                $stream = $mediaSource->getFileStream($data);

                return sprintf(self::DATA_PREFIX, $fileInfo['mime'], base64_encode($stream->getContents()));
            }
        }

        $file = $this->directory->getFile($data);

        if ($file->exists()) {
            return sprintf(self::DATA_PREFIX, $file->getMimeType(), base64_encode($file->read()));
        }

        throw new ExceptionMissingAsset('Assets ' . $data . ' not found at ' . $file->getPrefix());
    }
604783
private function hashContent(string $data) {
    $hash = hash_hmac(
      $this->algorithm,
      $data,
      $this->key
    );

    return $this->validate($hash);
  }
1048686
static function makeBase64URI(string $data) {
        $img = \getimagesizefromstring($data);
        if(!$img) {
            throw new \InvalidArgumentException('Bad input data');
        }
        
        return 'data:'.$img['mime'].';base64,'.\base64_encode($data);
    }
566533
protected function _serialize($data)
	{
		if (is_array($data))
		{
			foreach ($data as $key => $val)
			{
				if (is_string($val))
				{
					$data[$key] = str_replace('\\', '{{slash}}', $val);
				}
			}
		}
		else
		{
			if (is_string($data))
			{
				$data = str_replace('\\', '{{slash}}', $data);
			}
		}

		return serialize($data);
	}
1143769
public function encrypt(string $data): string
    {
        try {
            return Crypto::encrypt($data, $this->key);
        } catch(EnvironmentIsBrokenException $e) {
            throw new CryptoException($e->getMessage(), $e->getCode(), $e);
        }
    }
1155919
public function secureHash($data) {
        $salt = $this->_getCryptKey();
        return hash(self::HASH_ALGORITHM, sprintf('%s:%s', $salt, $data));
    }