Fr3nch13/CakePHP Utilities

CookieCryptTrait

Cookie Crypt Trait.

Provides the encrypt/decrypt logic for the CookieComponent.

Tags
link
https://book.cakephp.org/4/en/controllers/components/cookie.html

Table of Contents

Properties

$_validCiphers  : array<string|int, string>
Valid cipher names for encrypted cookies.

Methods

_checkCipher()  : void
Helper method for validating encryption cipher names.
_decode()  : array<string|int, mixed>|string
Decodes and decrypts a single value.
_decrypt()  : array<string|int, mixed>|string
Decrypts $value using public $type method in Security class
_encrypt()  : string
Encrypts $value using public $type method in Security class
_explode()  : array<string|int, mixed>|string
Explode method to return array from string set in CookieComponent::_implode() Maintains reading backwards compatibility with 1.x CookieComponent::_implode().
_getCookieEncryptionKey()  : string
Returns the encryption key to be used.
_implode()  : string
Implode method to keep keys are multidimensional arrays

Properties

$_validCiphers

Valid cipher names for encrypted cookies.

protected array<string|int, string> $_validCiphers = ['aes']

Methods

_checkCipher()

Helper method for validating encryption cipher names.

protected _checkCipher(string $encrypt) : void
Parameters
$encrypt : string

The cipher name.

Tags
throws
RuntimeException

When an invalid cipher is provided.

_decode()

Decodes and decrypts a single value.

protected _decode(string $value, string|false $encrypt, string|null $key) : array<string|int, mixed>|string
Parameters
$value : string

The value to decode & decrypt.

$encrypt : string|false

The encryption cipher to use.

$key : string|null

Used as the security salt if specified.

Return values
array<string|int, mixed>|string

Decoded values.

_decrypt()

Decrypts $value using public $type method in Security class

protected _decrypt(array<string|int, string>|string $values, string|false $mode[, string|null $key = null ]) : array<string|int, mixed>|string
Parameters
$values : array<string|int, string>|string

Values to decrypt

$mode : string|false

Encryption mode

$key : string|null = null

Used as the security salt if specified.

Return values
array<string|int, mixed>|string

Decrypted values

_encrypt()

Encrypts $value using public $type method in Security class

protected _encrypt(array<string|int, mixed>|string $value, string|false $encrypt[, string|null $key = null ]) : string
Parameters
$value : array<string|int, mixed>|string

Value to encrypt

$encrypt : string|false

Encryption mode to use. False disabled encryption.

$key : string|null = null

Used as the security salt if specified.

Return values
string

Encoded values

_explode()

Explode method to return array from string set in CookieComponent::_implode() Maintains reading backwards compatibility with 1.x CookieComponent::_implode().

protected _explode(string $string) : array<string|int, mixed>|string
Parameters
$string : string

A string containing JSON encoded data, or a bare string.

Return values
array<string|int, mixed>|string

Map of key and values

_getCookieEncryptionKey()

Returns the encryption key to be used.

protected abstract _getCookieEncryptionKey() : string
Return values
string

_implode()

Implode method to keep keys are multidimensional arrays

protected _implode(array<string|int, mixed> $array) : string
Parameters
$array : array<string|int, mixed>

Map of key and values

Return values
string

A JSON encoded string.


        
On this page

Search results