XpressEngine Core  1.11.2
 All Classes Namespaces Files Functions Variables Pages
Public Member Functions | Static Public Member Functions | List of all members
Password Class Reference

Public Member Functions

 getSupportedAlgorithms ()
 Return the list of hashing algorithms supported by this server. More...
 
 getBestAlgorithm ()
 Return the best hashing algorithm supported by this server. More...
 
 getCurrentlySelectedAlgorithm ()
 Return the currently selected hashing algorithm. More...
 
 getWorkFactor ()
 Return the currently configured work factor for bcrypt and other adjustable algorithms. More...
 
 createHash ($password, $algorithm=null)
 Create a hash using the specified algorithm. More...
 
 checkPassword ($password, $hash, $algorithm=null)
 Check if a password matches a hash. More...
 
 checkAlgorithm ($hash)
 Check the algorithm used to create a hash. More...
 
 checkWorkFactor ($hash)
 Check the work factor of a hash. More...
 
 createSecureSalt ($length, $format= 'hex')
 Generate a cryptographically secure random string to use as a salt. More...
 
 createTemporaryPassword ($length=16)
 Generate a temporary password using the secure salt generator. More...
 
 pbkdf2 ($password, $salt, $algorithm= 'sha256', $iterations=8192, $length=24)
 Generate the PBKDF2 hash of a string using a salt. More...
 
 bcrypt ($password, $salt=null)
 Generate the bcrypt hash of a string using a salt. More...
 
 strcmpConstantTime ($a, $b)
 Compare two strings in constant time. More...
 

Static Public Member Functions

static createSignature ($string)
 Create a digital signature to verify the authenticity of a string. More...
 
static checkSignature ($string, $signature)
 Check whether a signature is valid. More...
 
static getSecretKey ()
 Get the secret key for this site. More...
 

Detailed Description

Definition at line 13 of file Password.class.php.

Member Function Documentation

Password::bcrypt (   $password,
  $salt = null 
)

Generate the bcrypt hash of a string using a salt.

Parameters
string$passwordThe password
string$saltThe salt (optional, auto-generated if empty)
Returns
string

Definition at line 418 of file Password.class.php.

Password::checkAlgorithm (   $hash)

Check the algorithm used to create a hash.

Parameters
string$hashThe hash
Returns
string

Definition at line 174 of file Password.class.php.

Password::checkPassword (   $password,
  $hash,
  $algorithm = null 
)

Check if a password matches a hash.

Parameters
string$passwordThe password
string$hashThe hash
string$algorithmThe algorithm (optional)
Returns
bool

Definition at line 133 of file Password.class.php.

static Password::checkSignature (   $string,
  $signature 
)
static

Check whether a signature is valid.

Parameters
string$string
string$signature
Returns
bool

Definition at line 349 of file Password.class.php.

Password::checkWorkFactor (   $hash)

Check the work factor of a hash.

Parameters
string$hashThe hash
Returns
int

Definition at line 207 of file Password.class.php.

Password::createHash (   $password,
  $algorithm = null 
)

Create a hash using the specified algorithm.

Parameters
string$passwordThe password
string$algorithmThe algorithm (optional)
Returns
string

Definition at line 94 of file Password.class.php.

Password::createSecureSalt (   $length,
  $format = 'hex' 
)

Generate a cryptographically secure random string to use as a salt.

Parameters
int$lengthThe number of bytes to return
string$formathex or alnum
Returns
string

Definition at line 229 of file Password.class.php.

static Password::createSignature (   $string)
static

Create a digital signature to verify the authenticity of a string.

Parameters
string$string
Returns
string

Definition at line 335 of file Password.class.php.

Password::createTemporaryPassword (   $length = 16)

Generate a temporary password using the secure salt generator.

Parameters
int$lengthThe number of bytes to return
Returns
string

Definition at line 311 of file Password.class.php.

Password::getBestAlgorithm ( )

Return the best hashing algorithm supported by this server.

Returns
string

Definition at line 38 of file Password.class.php.

Password::getCurrentlySelectedAlgorithm ( )

Return the currently selected hashing algorithm.

Returns
string

Definition at line 48 of file Password.class.php.

static Password::getSecretKey ( )
static

Get the secret key for this site.

Returns
bool

Definition at line 366 of file Password.class.php.

Password::getSupportedAlgorithms ( )

Return the list of hashing algorithms supported by this server.

Returns
array

Definition at line 19 of file Password.class.php.

Password::getWorkFactor ( )

Return the currently configured work factor for bcrypt and other adjustable algorithms.

Returns
int

Definition at line 70 of file Password.class.php.

Password::pbkdf2 (   $password,
  $salt,
  $algorithm = 'sha256',
  $iterations = 8192,
  $length = 24 
)

Generate the PBKDF2 hash of a string using a salt.

Parameters
string$passwordThe password
string$saltThe salt
string$algorithmThe algorithm (optional, default is sha256)
int$iterationsIteration count (optional, default is 8192)
int$lengthThe length of the hash (optional, default is 32)
Returns
string

Definition at line 388 of file Password.class.php.

Password::strcmpConstantTime (   $a,
  $b 
)

Compare two strings in constant time.

Parameters
string$aThe first string
string$bThe second string
Returns
bool

Definition at line 433 of file Password.class.php.


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