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) : mixed
since

1.0

Arguments

cipher

\Joomla\Crypt\CipherInterfaceThe encryption cipher object.

key

\Joomla\Crypt\KeyThe encryption key[/pair)].

Response

mixed

decrypt

Method to decrypt a data string.

decrypt(string data) : string
since

1.0

throws

\Joomla\Crypt\Exception\DecryptionExceptionif the data cannot be decrypted

\Joomla\Crypt\Exception\InvalidKeyTypeExceptionif the key is not valid for the cipher

\Joomla\Crypt\Exception\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(string data) : string
since

1.0

throws

\Joomla\Crypt\Exception\EncryptionExceptionif the data cannot be encrypted

\Joomla\Crypt\Exception\InvalidKeyTypeExceptionif the key is not valid for the cipher

\Joomla\Crypt\Exception\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(array options = []) : \Joomla\Crypt\Key
since

1.0

throws

\Joomla\Crypt\Exception\InvalidKeyExceptionif the key cannot be generated

\Joomla\Crypt\Exception\UnsupportedCipherExceptionif the cipher is not supported on the current environment

Arguments

options

arrayKey generation options.

Response

\Joomla\Crypt\Key

genRandomBytes

Generate random bytes.

genRandomBytes(int length = 16) : string
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

\Joomla\Crypt\KeyThe key object to set.

Response

\Joomla\Crypt\CryptInstance of $this to allow chaining.

Properties

cipher

The encryption cipher object.

since

1.0

Type(s)

\Joomla\Crypt\CipherInterface

key

The encryption key[/pair)].

since

1.0

Type(s)

\Joomla\Crypt\Key