Documentation

Encryption
in package

Symmetric encryption for secrets that have to be stored and read back, like third-party credentials in the database. The key is the `encryption_key` setting of z_settings.ini.

Format: zenc:<cipher>: + base64url(payload). Every value names its cipher, so a new DEFAULT_CIPHER only affects new values while stored ones stay readable as long as their cipher remains in CIPHERS. The cipher key is derived per cipher, so a value relabeled with another cipher fails to decrypt.

Table of Contents

MIN_KEY_LENGTH  = 32
SETTING  = "encryption_key"
CIPHERS  = ["aes-256-gcm" => ZubZetFrameworkSecuritySecretsCipherAesGcmCipher::class]
Released identifiers are stored in values and must never change.
DEFAULT_CIPHER  = "aes-256-gcm"
MARKER  = "zenc"
decryptSecret()  : string
Decrypt a value created by encryptSecret().
encryptSecret()  : string
base64UrlDecode()  : string|null
base64UrlEncode()  : string
key()  : string
Derive a 256-bit key for one cipher from the configured setting.

Constants

CIPHERS

Released identifiers are stored in values and must never change.

private mixed CIPHERS = ["aes-256-gcm" => ZubZetFrameworkSecuritySecretsCipherAesGcmCipher::class]

DEFAULT_CIPHER

private mixed DEFAULT_CIPHER = "aes-256-gcm"

Methods

decryptSecret()

Decrypt a value created by encryptSecret().

public static decryptSecret(string $encrypted) : string
Parameters
$encrypted : string
Tags
throws
DecryptionException

When the key is wrong or the value is malformed or modified

Return values
string —

encryptSecret()

public static encryptSecret(string $plaintext) : string
Parameters
$plaintext : string
Return values
string —

base64UrlDecode()

private static base64UrlDecode(string $encoded) : string|null
Parameters
$encoded : string
Return values
string|null —

base64UrlEncode()

private static base64UrlEncode(string $bytes) : string
Parameters
$bytes : string
Return values
string —

key()

Derive a 256-bit key for one cipher from the configured setting.

private static key(string $cipherId) : string
Parameters
$cipherId : string
Return values
string —

Search results