/**
* Instantiate a signature-processor
*
- * @param $secret
- * String, private.
- * @param $paramNames
+ * @param string $secret
+ * private.
+ * @param array $paramNames
* Array, fields which should be part of the signature.
*/
public function __construct($secret, $paramNames) {
/**
* Generate a signature for a set of key-value pairs
*
- * @param $params
+ * @param array $params
* Array, key-value pairs.
- * @param $salt
- * String, the salt (if known) or NULL (for auto-generated).
+ * @param string $salt
+ * the salt (if known) or NULL (for auto-generated).
* @return string, the full public token representing the signature
*/
public function sign($params, $salt = NULL) {
$message['payload'] = array();
if (empty($salt)) {
$message['salt'] = $this->createSalt();
- } else {
- $message['salt'] = $salt;
+ }
+ else {
+ $message['salt'] = $salt;
}
// recall: paramNames is pre-sorted for stability
foreach ($this->paramNames as $paramName) {
if (is_numeric($params[$paramName])) {
$params[$paramName] = (string) $params[$paramName];
}
- } else { // $paramName is not included or ===NULL
- $params[$paramName] = '';
}
- $message['payload'][$paramName] = $params[$paramName];
+ else {// $paramName is not included or ===NULL
+ $params[$paramName] = '';
}
+ $message['payload'][$paramName] = $params[$paramName];
+ }
$token = $message['salt'] . $this->signDelim . md5(serialize($message));
return $token;
}
/**
* Determine whether a token represents a proper signature for $params
*
- * @param $token
- * String, the full public token representing the signature.
- * @param $params
+ * @param string $token
+ * the full public token representing the signature.
+ * @param array $params
* Array, key-value pairs.
*
* @throws Exception