Download the PHP package dwgebler/encryption without Composer
On this page you can find all versions of the php package dwgebler/encryption. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dwgebler/encryption
More information about dwgebler/encryption
Files in dwgebler/encryption
Package encryption
Short Description Encryption wrapper for PHP using libsodium — simple API for symmetric and asymmetric encryption, password hashing, digital signing, and message authentication.
License MIT
Informations about the package encryption
php-encryption
A small PHP wrapper around libsodium, providing focused classes for password hashing, symmetric encryption, asymmetric encryption, digital signing, and message authentication.
Upgrading from 1.x? See UPGRADE-2.0.md — 2.0 is a
clean break that fixes several security issues, including a critical issue
with 1.x hashPassword(). Read the security advisory at the top of
UPGRADE-2.0.md if you stored 1.x password hashes.
Requirements
- PHP 8.2 or higher
ext-sodium(bundled with PHP since 7.2)
Installation
Quick start
The Encryption object is a facade — call accessors to reach each
primitive:
Keys at the API boundary are raw bytes. Use the Encoding helper to
convert between raw bytes and hex / base64 when persisting or transmitting
keys.
Password hashing (for storing user passwords)
Uses Argon2id with OPSLIMIT_MODERATE / MEMLIMIT_MODERATE by default.
Configure stronger or weaker parameters via the constructor:
Symmetric encryption
With a password (Argon2id-derived key)
With a 32-byte key
Wrong-length keys throw InvalidKeyException. There is no silent stretching.
Asymmetric encryption
Authenticated (Alice → Bob, both identified)
Anonymous (sender hidden)
Digital signatures (Ed25519)
Attached signature
Detached signature
Message authentication (shared secret)
Exceptions
The library uses two distinct exception trees:
Gebler\Encryption\Exception\EncryptionException (extends RuntimeException)
— runtime crypto failures. Catch this base type to handle any cipher /
signature failure at once.
| Subclass | Thrown when |
|---|---|
DecryptionFailedException |
Wrong key, wrong password, tampered ciphertext, signature verification failure |
SodiumOperationException |
Underlying sodium primitive raised SodiumException |
\InvalidArgumentException — input-shape errors (programmer mistakes
detectable at the call site, separate from crypto failures):
| Exception | Thrown when |
|---|---|
Gebler\Encryption\Exception\InvalidKeyException |
Key or signature has wrong length |
\InvalidArgumentException (directly) |
Plaintext / message is empty |
To handle everything, catch both EncryptionException and
\InvalidArgumentException.
License
MIT.
All versions of encryption with dependencies
ext-sodium Version *