You are here

public static function secureCookieBasic::create in Secure Cookie Data 7

Generates the ciphered hash for the given data, algorithm and secret key.

Parameters

$data string: The data that constitutes the message to be digested.

self::$__secret string: The key for computing the crypto message digest.

Return value

string The message digest in hexadecimal.

2 calls to secureCookieBasic::create()
secureCookieBasic::validate in ./secure_cookie_data.class.inc
Verifies the message digest for the given data, algorithm and secret key.
secure_cookie_data_put in ./secure_cookie_data.module
Sets the secure cookie with the given data.

File

./secure_cookie_data.class.inc, line 58
secure_cookie.class.inc @author António P. P. Almeida <appa@perusio.net> @date Wed Dec 21 03:17:53 2011

Class

secureCookieBasic
@file secure_cookie.class.inc @author António P. P. Almeida <appa@perusio.net> @date Wed Dec 21 03:17:53 2011

Code

public static function create($data = NULL) {

  // Cookies cannot contain ',' and ';' therefore we must encode the JSON
  // object in base64.
  $encoded_data = self::encode($data);

  // Compute the HMAC.
  return hash_hmac(self::$__algorithm, $encoded_data, hash_hmac(self::$__algorithm, $encoded_data, self::$__secret));
}