Drupal 8  8.0.2
Crypt Class Reference

Static Public Member Functions

static randomBytes ($count)
 
static hmacBase64 ($data, $key)
 
static hashBase64 ($data)
 
static hashEquals ($known_string, $user_string)
 
static randomBytesBase64 ($count=32)
 

Detailed Description

Utility class for cryptographically-secure string handling routines.

Member Function Documentation

static hashBase64 (   $data)
static
static hashEquals (   $known_string,
  $user_string 
)
static

Compares strings in constant time.

Parameters
string$known_stringThe expected string.
string$user_stringThe user supplied string to check.
Returns
bool Returns TRUE when the two strings are equal, FALSE otherwise.

Referenced by PhpassHashedPassword\check(), ToolbarController\checkSubTreeAccess(), UserController\confirmCancel(), and UserController\resetPass().

Here is the caller graph for this function:

static hmacBase64 (   $data,
  $key 
)
static

Calculates a base-64 encoded, URL-safe sha-256 hmac.

Parameters
mixed$dataScalar value to be validated with the hmac.
mixed$keyA secret key, this can be any scalar value.
Returns
string A base-64 encoded sha-256 hmac, with + replaced with -, / with _ and any = padding characters removed.

Referenced by CsrfTokenGenerator\computeToken(), EntityAutocompleteTest\getAutocompleteResult(), ImageStyle\getPathToken(), EntityAutocompleteController\handleAutocomplete(), EntityAutocomplete\processEntityAutocomplete(), UpdateProcessor\processFetchTask(), ImageStyleTest\testGetPathToken(), CryptTest\testHmacBase64(), CryptTest\testHmacBase64Invalid(), and EntityAutocompleteTest\testSelectionSettingsHandling().

Here is the caller graph for this function:

static randomBytes (   $count)
static

Returns a string of highly randomized bytes (over the full 8-bit range).

This function is better than simply calling mt_rand() or any other built-in PHP function because it can return a long string of bytes (compared to < 4 bytes normally from mt_rand()) and uses the best available pseudo-random source.

Parameters
int$countThe number of characters (bytes) to return in the string.
Returns
string A randomly generated string.

Referenced by DrupalKernel\boot(), Php\generate(), PhpassHashedPassword\generateSalt(), and CryptTest\testRandomBytes().

Here is the caller graph for this function:

static randomBytesBase64 (   $count = 32)
static

Returns a URL-safe, base64 encoded string of highly randomized bytes.

Parameters
$byte_countThe number of random bytes to fetch and base64 encode.
Returns
string The base64 encoded result will have a length of up to 4 * $byte_count.
See Also
::randomBytes()

Referenced by PrivateKey\create(), CsrfTokenGenerator\get(), FormCache\getCache(), Html\getUniqueId(), FormBuilder\prepareForm(), UpdatePathTestBase\prepareSettings(), FormBuilder\rebuildForm(), SessionManager\regenerate(), PrivateKeyTest\setUp(), PermissionsHashGeneratorTest\setUp(), CsrfTokenGeneratorTest\setupDefaultExpectations(), SessionManager\start(), SimpleTestTest\stubTest(), SiteSettingsForm\submitForm(), and CsrfTokenGeneratorTest\testGenerateSeedOnGet().

Here is the caller graph for this function:


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