Crypt
Crypt is a Joomla Platform class for handling basic encryption/decryption of data.
| since |
3.0.0 |
|---|---|
| package |
Joomla CMS |
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) : mixed
| since |
3.0.0 |
|---|
Arguments
- cipher
\Joomla\CMS\Crypt\CipherInterfaceThe encryption cipher object.- key
\Joomla\CMS\Crypt\KeyThe encryption key[/pair)].
Response
mixed
decrypt
Method to decrypt a data string.
decrypt(string data) : string
| since |
3.0.0 |
|---|---|
| throws |
|
Arguments
- data
stringThe encrypted string to decrypt.
Response
stringThe decrypted data string.
encrypt
Method to encrypt a data string.
encrypt(string data) : string
| since |
3.0.0 |
|---|
Arguments
- data
stringThe data string to encrypt.
Response
stringThe encrypted data string.
generateKey
Method to generate a new encryption key[/pair] object.
generateKey(array options = array()) : \Joomla\CMS\Crypt\Key
| since |
3.0.0 |
|---|
Arguments
- options
arrayKey generation options.
Response
\Joomla\CMS\Crypt\Key
genRandomBytes
Generate random bytes.
genRandomBytes(int length = 16) : string
| since |
3.0.0 |
|---|
Arguments
- length
intLength of the random data to generate
Response
stringRandom binary data
hasStrongPasswordSupport
Tests for the availability of updated crypt().
hasStrongPasswordSupport() : bool
Based on a method by Anthony Ferrera
| note |
To be removed when PHP 5.3.7 or higher is the minimum supported version. |
|---|---|
| link | |
| since |
3.2 |
| deprecated |
4.0 |
Response
boolAlways returns true since 3.3
safeStrlen
Safely detect a string's length
safeStrlen(string str) : int
This method is derived from \ParagonIE\Halite\Util::safeStrlen()
| since |
3.5 |
|---|---|
| ref |
mbstring.func_overload |
| throws |
|
Arguments
- str
stringString to check the length of
Response
int
safeSubstr
Safely extract a substring
safeSubstr(string str, int start, int length = null) : string
This method is derived from \ParagonIE\Halite\Util::safeSubstr()
| since |
3.5 |
|---|
Arguments
- str
stringThe string to extract the substring from- start
intThe starting position to extract from- length
intThe 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
| since |
3.0.0 |
|---|
Arguments
- key
\Joomla\CMS\Crypt\KeyThe key object to set.
Response
\Joomla\CMS\Crypt\Crypt
timingSafeCompare
A timing safe comparison method.
timingSafeCompare(string known, string unknown) : bool
This defeats hacking attempts that use timing based attack vectors.
NOTE: Length will leak.
| since |
3.2 |
|---|
Arguments
- known
stringA known string to check against.- unknown
stringAn unknown string to check.
Response
boolTrue if the two strings are exactly the same.
Properties
_cipher
The encryption cipher object.
| since |
3.0.0 |
|---|
Type(s)
\Joomla\CMS\Crypt\CipherInterface
_key
The encryption key[/pair)].
| since |
3.0.0 |
|---|
Type(s)
\Joomla\CMS\Crypt\Key