Sodium

Implements CipherInterface

Cipher for sodium algorithm encryption, decryption and key generation.

since

1.4.0

package

Joomla Framework

Methods

decrypt

Method to decrypt a data string.

decrypt(string data, \Joomla\Crypt\Key key) : string
since

1.4.0

throws

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

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

Arguments

data

stringThe encrypted string to decrypt.

key

\Joomla\Crypt\KeyThe key object to use for decryption.

Response

stringThe decrypted data string.

encrypt

Method to encrypt a data string.

encrypt(string data, \Joomla\Crypt\Key key) : string
since

1.4.0

throws

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

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

Arguments

data

stringThe data string to encrypt.

key

\Joomla\Crypt\KeyThe key object to use for encryption.

Response

stringThe encrypted data string.

generateKey

Method to generate a new encryption key object.

generateKey(array options = []) : \Joomla\Crypt\Key
since

1.4.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

isSupported

Check if the cipher is supported in this environment.

isSupported() : bool
static
since

2.0.0

Response

bool

setNonce

Set the nonce to use for encrypting/decrypting messages

setNonce(string nonce) : void
since

1.4.0

Arguments

nonce

stringThe message nonce

Properties

nonce

The message nonce to be used with encryption/decryption

since

1.4.0

Type(s)

string