Download the PHP package tezmanian/utils-crypto without Composer
On this page you can find all versions of the php package tezmanian/utils-crypto. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tezmanian/utils-crypto
More information about tezmanian/utils-crypto
Files in tezmanian/utils-crypto
Package utils-crypto
Short Description Authenticated AES-GCM encryption for PHP — supports AES-128/192/256-GCM with random nonces, tag verification, and a strict enum-based cipher allowlist. PHP 8.3+, requires ext-openssl.
License MIT
Homepage https://github.com/tezmanian/tez-utils-crypto
Informations about the package utils-crypto
tez-utils-crypto
Authenticated AES-GCM encryption for PHP — supports AES-128/192/256-GCM with random nonces, tag verification, and a strict enum-based cipher allowlist. PHP 8.3+, requires ext-openssl.
Installation
Package: tezmanian/utils-crypto · Namespace: Tezmanian\Utils\Crypto
Components
| Class | Purpose |
|---|---|
AesEncryptionService |
Encrypts and decrypts strings using authenticated AES-GCM |
AesCipher |
Enum allowlist of supported cipher variants with their parameters |
Encrypted format
A fresh random nonce is generated on every encrypt() call — identical plaintexts produce different ciphertexts. The GCM authentication tag is verified on decrypt(), so tampered data is always rejected.
Quick start
AesEncryptionService
Constructor
| Parameter | Description |
|---|---|
$hexKey |
Hex-encoded key — length must match the chosen cipher (see table below) |
$cipher |
Cipher variant — defaults to AesCipher::Aes256Gcm |
Throws InvalidArgumentException when the key length does not match the cipher.
Methods
decrypt() throws RuntimeException on invalid base64, too-short input, or authentication tag mismatch.
AesCipher
Enum acting as an explicit allowlist — only ciphers defined here may be used.
| Case | OpenSSL string | Key length | Hex key chars |
|---|---|---|---|
AesCipher::Aes128Gcm |
aes-128-gcm |
16 bytes / 128 bit | 32 |
AesCipher::Aes192Gcm |
aes-192-gcm |
24 bytes / 192 bit | 48 |
AesCipher::Aes256Gcm |
aes-256-gcm |
32 bytes / 256 bit | 64 (recommended) |
All variants use a 12-byte nonce (NIST-recommended) and a 16-byte authentication tag.
Selecting a cipher variant
Error handling
Requirements
- PHP 8.3+
ext-openssltezmanian/utils-enum^1.0
Development
License
MIT — see LICENSE.
Author: René Halberstadt