CipherService

Read onlyYes
FinalYes

Provides encryption and decryption based on XChaCha20-Poly1305.

Table of Contents

Methods

decrypt()  : string
Decrypts the provided cipher value using a shared key and optional additional authenticated data.
encrypt()  : CipherValue
Encrypts the provided plain text using a shared key and additional authenticated data.

Methods

decrypt()

Decrypts the provided cipher value using a shared key and optional additional authenticated data.

public decrypt(CipherValue $cipherValue, SharedKey $key[, string $additionalData = '' ]) : string
Parameters
$cipherValue : CipherValue

The cipher value containing encrypted data and nonce.

$key : SharedKey

The shared key used for decryption.

$additionalData : string = ''

Optional additional authenticated data that was included during encryption.

Tags
throws
CipherDecryptionFailedException

If decryption fails or the integrity check is invalid.

Return values
string

encrypt()

Encrypts the provided plain text using a shared key and additional authenticated data.

public encrypt(string $plainText, SharedKey $key[, string $additionalData = '' ]) : CipherValue
Parameters
$plainText : string

The plain text to be encrypted.

$key : SharedKey

The shared key used for encryption.

$additionalData : string = ''

Optional additional authenticated data that will be included in the encryption.

Return values
CipherValue

        
On this page

Search results