/** * Quickly hash the message using the assigned key using randomness. * * @param string $msg The message to be short hashed. * @param string $key The key to hash the message against. * @return string * @throws Exceptions\InvalidTypeException */ public static function shortHash($msg, $key) { # Test the message and key for string validity. Helpers::isString($msg, 'Hash', 'shortHash'); Helpers::isString($key, 'Hash', 'shortHash'); return \Sodium\crypto_shorthash($msg, $key); }
/** * Compute an integer key for shared memory * * @param string $lookup * @return string */ public function getSHMKey(string $lookup) : string { return Base64UrlSafe::encode(\Sodium\crypto_shorthash($this->personalization . $lookup, $this->cacheKeyL) . \Sodium\crypto_shorthash($this->personalization . $lookup, $this->cacheKeyR)); }