Utility functions for generating hashes.
More...
|
| static | hash ( $data, $raw=true) |
| | Generate a cryptographic hash value (message digest) for a string, making use of the best hash algorithm that we have available.
|
| |
| static | hashAlgo () |
| | Decide on the best acceptable hash algorithm we have available for hash()
|
| |
| static | hashLength ( $raw=true) |
| | Return the byte-length output of the hash algorithm we are using in self::hash and self::hmac.
|
| |
| static | hmac ( $data, $key, $raw=true) |
| | Generate a keyed cryptographic hash value (HMAC) for a string, making use of the best hash algorithm that we have available.
|
| |
|
| static string | $algo = null |
| | The hash algorithm being used.
|
| |
| static int | $hashLength |
| | The number of bytes outputted by the hash algorithm.
|
| |
Utility functions for generating hashes.
This is based in part on Drupal code as well as what we used in our own code prior to introduction of this class, by way of MWCryptRand.
Definition at line 18 of file MWCryptHash.php.
◆ hash()
| static Wikimedia\MWCryptHash::hash |
( |
| $data, |
|
|
| $raw = true ) |
|
static |
Generate a cryptographic hash value (message digest) for a string, making use of the best hash algorithm that we have available.
- Parameters
-
| string | $data | |
| bool | $raw | True to return binary data, false to return it hex-encoded |
- Returns
- string A hash of the data
Definition at line 76 of file MWCryptHash.php.
◆ hashAlgo()
| static Wikimedia\MWCryptHash::hashAlgo |
( |
| ) |
|
|
static |
Decide on the best acceptable hash algorithm we have available for hash()
- Returns
- string A hash algorithm
Definition at line 33 of file MWCryptHash.php.
◆ hashLength()
| static Wikimedia\MWCryptHash::hashLength |
( |
| $raw = true | ) |
|
|
static |
Return the byte-length output of the hash algorithm we are using in self::hash and self::hmac.
- Parameters
-
| bool | $raw | True to return the length for binary data, false to return for hex-encoded |
- Returns
- int Number of bytes the hash outputs
Definition at line 60 of file MWCryptHash.php.
◆ hmac()
| static Wikimedia\MWCryptHash::hmac |
( |
| $data, |
|
|
| $key, |
|
|
| $raw = true ) |
|
static |
Generate a keyed cryptographic hash value (HMAC) for a string, making use of the best hash algorithm that we have available.
- Parameters
-
| string | $data | |
| string | $key | |
| bool | $raw | True to return binary data, false to return it hex-encoded |
- Returns
- string An HMAC hash of the data + key
Definition at line 89 of file MWCryptHash.php.
◆ $algo
| string Wikimedia\MWCryptHash::$algo = null |
|
staticprotected |
◆ $hashLength
| int Wikimedia\MWCryptHash::$hashLength |
|
staticprotected |
The number of bytes outputted by the hash algorithm.
Definition at line 27 of file MWCryptHash.php.
The documentation for this class was generated from the following file: