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
\JCryptCipherThe encryption cipher object.- $key
\JCryptKeyThe encryption key[/pair)].
decrypt
Method to decrypt a data string.
decrypt(string $data) : string
| since |
12.1 |
|---|
Arguments
- $data
stringThe encrypted string to decrypt.
Response
stringThe decrypted data string.
encrypt
Method to encrypt a data string.
encrypt(string $data) : string
| since |
12.1 |
|---|
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()) : \JCryptKey
genRandomBytes
Generate random bytes.
genRandomBytes(integer $length = 16) : string
| since |
12.1 |
|---|
Arguments
- $length
integerLength of the random data to generate
Response
stringRandom 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
stringA known string to check against.- $unknown
stringAn unknown string to check.
Response
booleanTrue if the two strings are exactly the same.