switon / crypto
Symmetric encryption, derived keys, plaintext validation, and key rotation for Switon Framework
v1.0.0
2026-06-06 13:43 UTC
Requires
- php: >=8.3
- ext-mbstring: *
- ext-openssl: *
- switon/cli: ^1.0
- switon/core: ^1.0
Requires (Dev)
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^2.0
- switon/testing: ^1.0
README
Symmetric encryption, derived keys, plaintext validation, and key rotation for Switon Framework.
Highlights
- One encryption contract:
CipherInterfacekeeps app code on one reversible boundary. - Plaintext validation:
ValidatorInterfacechecks decrypted text before acceptance. - Rotation support:
RotatingCipherkeeps legacy ciphertext readable during migration windows. - Key generation:
KeyCommandprints fresh application keys.
Installation
composer require switon/crypto
Quick Start
After you wire CipherInterface in switon.yml, inject it and use normal encrypt() / decrypt() calls.
namespace App\Service; use Switon\Core\Attribute\Autowired; use Switon\Crypto\CipherInterface; final class UserSecretService { #[Autowired] protected CipherInterface $cipher; public function encryptProfile(string $payload): string { return $this->cipher->encrypt($payload, 'tenant:acme'); } }
Docs: https://docs.switon.dev/latest/crypto
License
MIT.