Elgg
Version 6.1
|
Cryptographic services. More...
Public Member Functions | |
getRandomString ($length, $chars=null) | |
Generate a random string of specified length. More... | |
areEqual ($str1, $str2) | |
Are two strings equal (compared in constant time)? More... | |
Public Attributes | |
const | CHARS_PASSWORD = 'bcdfghjklmnpqrstvwxyz2346789' |
Character set for temp passwords (no risk of embedded profanity/glyphs that look similar) More... | |
const | CHARS_HEX = '0123456789abcdef' |
Character set for hexadecimal. More... | |
Protected Member Functions | |
strlen ($binary_string) | |
Count the number of bytes in a string. More... | |
Cryptographic services.
Definition at line 12 of file Crypto.php.
Elgg\Security\Crypto::areEqual | ( | $str1, | |
$str2 | |||
) |
Are two strings equal (compared in constant time)?
string | $str1 | First string to compare |
string | $str2 | Second string to compare |
Based on password_verify in PasswordCompat
Definition at line 93 of file Crypto.php.
Elgg\Security\Crypto::getRandomString | ( | $length, | |
$chars = null |
|||
) |
Generate a random string of specified length.
Uses supplied character list for generating the new string. If no character list provided - uses Base64 URL character set.
int | $length | Desired length of the string |
string | null | $chars | Characters to be chosen from randomly. If not given, the Base64 URL charset will be used. |
Definition at line 43 of file Crypto.php.
|
protected |
Count the number of bytes in a string.
We cannot simply use strlen() for this, because it might be overwritten by the mbstring extension. In this case, strlen() will count the number of characters based on the internal encoding. A sequence of bytes might be regarded as a single multibyte character.
Use elgg_strlen() to count UTF-characters instead of bytes.
string | $binary_string | The input string |
From PasswordCompat
Definition at line 126 of file Crypto.php.
const Elgg\Security\Crypto::CHARS_HEX = '0123456789abcdef' |
Character set for hexadecimal.
Definition at line 22 of file Crypto.php.
const Elgg\Security\Crypto::CHARS_PASSWORD = 'bcdfghjklmnpqrstvwxyz2346789' |
Character set for temp passwords (no risk of embedded profanity/glyphs that look similar)
Definition at line 17 of file Crypto.php.