/** * @param int|string $userID * @param string $role * @return bool|string */ public function getAuthCookieValue($userID, $role) { $algo = function_exists('hash') ? 'sha256' : 'sha1'; return wfWAFUtils::hash_hmac($algo, $userID . $role . floor(time() / 43200), $this->getStorageEngine()->getConfig('authKey')); }
/** * @param string $action * @return bool|string */ public function createNonce($action) { $userInfo = $this->parseAuthCookie(); if ($userInfo === false) { $userInfo = array('userID' => 0, 'role' => ''); // Use an empty user like WordPress would } $userID = $userInfo['userID']; $role = $userInfo['role']; $algo = function_exists('hash') ? 'sha256' : 'sha1'; return wfWAFUtils::hash_hmac($algo, $action . $userID . $role . floor(time() / 43200), $this->getStorageEngine()->getConfig('authKey')); }