Crypt

Crypt is a Joomla Framework class for handling basic encryption/decryption of data.

since

1.0

package

Joomla Framework

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\Crypt\CipherInterface cipher = null, \Joomla\Crypt\Key key = null) : 
since

1.0

Arguments

cipher

CipherInterface|nullThe encryption cipher object.

key

Key|nullThe encryption key[/pair)].

Response

mixed

decrypt

Method to decrypt a data string.

decrypt( data) : 
since

1.0

throws

DecryptionExceptionif the data cannot be decrypted

InvalidKeyTypeExceptionif the key is not valid for the cipher

UnsupportedCipherExceptionif the cipher is not supported on the current environment

Arguments

data

stringThe encrypted string to decrypt.

Response

stringThe decrypted data string.

encrypt

Method to encrypt a data string.

encrypt( data) : 
since

1.0

throws

EncryptionExceptionif the data cannot be encrypted

InvalidKeyTypeExceptionif the key is not valid for the cipher

UnsupportedCipherExceptionif the cipher is not supported on the current environment

Arguments

data

stringThe data string to encrypt.

Response

stringThe encrypted data string.

generateKey

Method to generate a new encryption key[/pair] object.

generateKey(mixed||string|int options = []) : \Joomla\Crypt\Key
since

1.0

throws

InvalidKeyExceptionif the key cannot be generated

UnsupportedCipherExceptionif the cipher is not supported on the current environment

Arguments

options

array<string|int, mixed>Key generation options.

Response

Key

genRandomBytes

Generate random bytes.

genRandomBytes( length = 16) : 
static
since

1.0

Arguments

length

intLength of the random data to generate

Response

stringRandom binary data

setKey

Method to set the encryption key[/pair] object.

setKey(\Joomla\Crypt\Key key) : \Joomla\Crypt\Crypt
since

1.0

Arguments

key

KeyThe key object to set.

Response

CryptInstance of $this to allow chaining.

Properties

cipher

The encryption cipher object.

since

1.0

Type(s)

CipherInterface

key

The encryption key[/pair)].

since

1.0

Type(s)

Key