Symmetric encryption, derived keys, plaintext validation, and key rotation for Switon Framework.
- 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.
composer require switon/cryptoAfter 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
MIT.