/** * @param array $parameters * * @return string */ public function generate(array $parameters) { $shainString = ''; // All parameters need to be arranged alphabetically. ksort($parameters); foreach ($parameters as $key => $value) { // Parameters that do not have a value should NOT be included in the string to hash if (empty($value)) { continue; } // All parameter names should be in UPPERCASE (to avoid any case confusion). $key = strtoupper($key); if (in_array($key, static::$allowed, true) || $this->isWildcarded($key)) { $shainString .= sprintf('%s=%s%s', $key, $value, $this->token->getShain()); } } return strtoupper(sha1($shainString)); }