JCrypt
JCrypt is a Joomla Platform class for handling basic encryption/decryption of data.
package |
Joomla.Platform |
---|---|
subpackage |
Crypt |
since |
12.1 |
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(\JCryptCipher $cipher = null, \JCryptKey $key = null)
since |
12.1 |
---|
Arguments
- $cipher
\JCryptCipher
The encryption cipher object.- $key
\JCryptKey
The encryption key[/pair)].
decrypt
Method to decrypt a data string.
decrypt(string $data) : string
since |
12.1 |
---|
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 |
12.1 |
---|
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()) : \JCryptKey
genRandomBytes
Generate random bytes.
genRandomBytes(integer $length = 16) : string
since |
12.1 |
---|
Arguments
- $length
integer
Length of the random data to generate
Response
string
Random binary data
setKey
Method to set the encryption key[/pair] object.
setKey(\JCryptKey $key) : \JCrypt
timingSafeCompare
A timing safe comparison method. This defeats hacking attempts that use timing based attack vectors.
timingSafeCompare(string $known, string $unknown) : boolean
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.