KeyRotationDecorator
in package
implements
EncrypterInterface
Key Rotation Decorator
Wraps any EncrypterInterface implementation to provide automatic fallback to previous encryption keys during decryption. This enables seamless key rotation without requiring re-encryption of existing data.
Table of Contents
Interfaces
- EncrypterInterface
- CodeIgniter Encryption Handler
Properties
- $innerHandler : EncrypterInterface
- $previousKeys : array<string|int, mixed>
Methods
- __construct() : mixed
- __get() : array<string|int, mixed>|bool|int|string|null
- Delegate property access to the inner handler.
- __isset() : bool
- Delegate property existence check to inner handler.
- decrypt() : string
- Decrypt - convert ciphertext into plaintext
- encrypt() : string
- Encrypt - convert plaintext into ciphertext
Properties
$innerHandler read-only
private
EncrypterInterface
$innerHandler
$previousKeys read-only
private
array<string|int, mixed>
$previousKeys
Methods
__construct()
public
__construct(EncrypterInterface $innerHandler, array<int, string> $previousKeys) : mixed
Parameters
- $innerHandler : EncrypterInterface
-
The wrapped encryption handler
- $previousKeys : array<int, string>
-
Array of previous encryption keys
__get()
Delegate property access to the inner handler.
public
__get(string $key) : array<string|int, mixed>|bool|int|string|null
Parameters
- $key : string
Return values
array<string|int, mixed>|bool|int|string|null__isset()
Delegate property existence check to inner handler.
public
__isset(string $key) : bool
Parameters
- $key : string
Return values
booldecrypt()
Decrypt - convert ciphertext into plaintext
public
decrypt(mixed $data[, mixed $params = null ]) : string
Attempts decryption with current key first. If that fails and no explicit key was provided in $params, tries each previous key.
Parameters
- $data : mixed
-
Encrypted data
- $params : mixed = null
-
Overridden parameters, specifically the key
Tags
Return values
stringencrypt()
Encrypt - convert plaintext into ciphertext
public
encrypt(mixed $data[, mixed $params = null ]) : string
Encryption always uses the inner handler's current key.
Parameters
- $data : mixed
-
Input data
- $params : mixed = null
-
Overridden parameters, specifically the key