Crypt
Crypt is a Joomla Platform class for handling basic encryption/decryption of data.
since |
3.0.0 |
---|
Methods
__construct
Object Constructor takes an optional key to be used for encryption/decryption. If no key is given then the secret word from the configuration object is used.
__construct(\Joomla\CMS\Crypt\CipherInterface $cipher = null, \Joomla\CMS\Crypt\Key $key = null)
since |
3.0.0 |
---|
Arguments
- $cipher
\Joomla\CMS\Crypt\CipherInterface
The encryption cipher object.- $key
\Joomla\CMS\Crypt\Key
The encryption key[/pair)].
decrypt
Method to decrypt a data string.
decrypt(string $data) : string
since |
3.0.0 |
---|---|
throws |
|
Arguments
- $data
string
The encrypted string to decrypt.
Response
string
The decrypted data string.
encrypt
Method to encrypt a data string.
encrypt(string $data) : string
since |
3.0.0 |
---|
Arguments
- $data
string
The data string to encrypt.
Response
string
The encrypted data string.
generateKey
Method to generate a new encryption key[/pair] object.
generateKey(array $options = array()) : \Joomla\CMS\Crypt\Key
genRandomBytes
Generate random bytes.
genRandomBytes(integer $length = 16) : string
since |
3.0.0 |
---|
Arguments
- $length
integer
Length of the random data to generate
Response
string
Random binary data
hasStrongPasswordSupport
Tests for the availability of updated crypt().
hasStrongPasswordSupport() : boolean
Based on a method by Anthony Ferrera
note |
To be removed when PHP 5.3.7 or higher is the minimum supported version. |
---|---|
link |
https://github.com/ircmaxell/password_compat/blob/master/version-test.php |
since |
3.2 |
deprecated |
4.0 |
Response
boolean
Always returns true since 3.3
safeStrlen
Safely detect a string's length
safeStrlen(string $str) : integer
This method is derived from \ParagonIE\Halite\Util::safeStrlen()
since |
3.5 |
---|---|
ref |
mbstring.func_overload |
throws |
|
Arguments
- $str
string
String to check the length of
Response
integer
safeSubstr
Safely extract a substring
safeSubstr(string $str, integer $start, integer $length = null) : string
This method is derived from \ParagonIE\Halite\Util::safeSubstr()
since |
3.5 |
---|
Arguments
- $str
string
The string to extract the substring from- $start
integer
The starting position to extract from- $length
integer
The length of the string to return
Response
string
setKey
Method to set the encryption key[/pair] object.
setKey(\Joomla\CMS\Crypt\Key $key) : \Joomla\CMS\Crypt\Crypt
timingSafeCompare
A timing safe comparison method.
timingSafeCompare(string $known, string $unknown) : boolean
This defeats hacking attempts that use timing based attack vectors.
NOTE: Length will leak.
since |
3.2 |
---|
Arguments
- $known
string
A known string to check against.- $unknown
string
An unknown string to check.
Response
boolean
True if the two strings are exactly the same.