spunQ_Crypto Class Reference

Class for cryptographic functions. More...

List of all members.

Static Public Member Functions

static randomSalt ()
 Generate a random 256bit-salt.
static encrypt ($data, $salt)
 Encrypt data with given salt (use randomSalt() to generate one).
static verify ($data, $encrypted, $salt)
 Verify data by comparing it to encrypted value.
static safeHash ($data, $salt)
 Generates a hash that can be published.
static verifySafeHash ($safeHash, $encrypted, $salt)
 Verifies a hash generated by safeHash().

Static Private Member Functions

static hash ($data, $salt, $rounds)
 Creates a hash with the given number of rounds.


Detailed Description

Class for cryptographic functions.

Definition at line 6 of file Crypto.class.php.


Member Function Documentation

static spunQ_Crypto::encrypt ( data,
salt 
) [static]

Encrypt data with given salt (use randomSalt() to generate one).

The encrypted data can be verified by encrypting the same data with the same salt. The result should be identical. This is what verify() does.

Parameters:
$data The data to encrypt.
$salt The salt value to use.
Returns:
string

Definition at line 25 of file Crypto.class.php.

static spunQ_Crypto::hash ( data,
salt,
rounds 
) [static, private]

Creates a hash with the given number of rounds.

Parameters:
$data The data to encrypt.
$salt The salt value to use.
$rounds Number of rounds to encrypt.
Returns:
string

Definition at line 72 of file Crypto.class.php.

static spunQ_Crypto::randomSalt (  )  [static]

Generate a random 256bit-salt.

Returns:
string

Definition at line 12 of file Crypto.class.php.

static spunQ_Crypto::safeHash ( data,
salt 
) [static]

Generates a hash that can be published.

This function should be used whenever a hash value must leave the system. It provides a hash value (a string) that can be sent as a cookie, for example, to keep users logged in.

Parameters:
$data The data to encrypt.
$salt The salt value to use.
Returns:
string

Definition at line 49 of file Crypto.class.php.

static spunQ_Crypto::verify ( data,
encrypted,
salt 
) [static]

Verify data by comparing it to encrypted value.

Parameters:
$data The data to verify.
$encrypted Previously encrypted data.
$salt The salt that was used for the encryption.
Returns:
boolean

Definition at line 36 of file Crypto.class.php.

static spunQ_Crypto::verifySafeHash ( safeHash,
encrypted,
salt 
) [static]

Verifies a hash generated by safeHash().

Same as verify(), but for return values of the safeHash() function.

Parameters:
$safeHash Return value of the safeHash() function.
$encrypted Previously encrypted data (using encrypt()).
$salt The salt that was used for the encryption.
Returns:
boolean

Definition at line 61 of file Crypto.class.php.


The documentation for this class was generated from the following file:

Generated on Fri Jul 1 11:12:39 2011 for spunQ3 by  doxygen 1.5.9