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
since

12.1

Arguments

$options

arrayKey generation options.

Response

\JCryptKey

genRandomBytes

Generate random bytes.

genRandomBytes(integer $length = 16) : string
static
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
since

12.1

Arguments

$key

\JCryptKeyThe key object to set.

Response

\JCrypt

timingSafeCompare

A timing safe comparison method. This defeats hacking attempts that use timing based attack vectors.

timingSafeCompare(string $known, string $unknown) : boolean
static
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.

Properties

_cipher

The encryption cipher object.

since

12.1

Type(s)

\JCryptCipher

_key

The encryption key[/pair)].

since

12.1

Type(s)

\JCryptKey