switon/crypto

Symmetric encryption, derived keys, plaintext validation, and key rotation for Switon Framework

Maintainers

Package info

github.com/switon-php/crypto

Documentation

pkg:composer/switon/crypto

Statistics

Installs: 4

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-06-06 13:43 UTC

This package is auto-updated.

Last update: 2026-06-07 04:39:21 UTC


README

CI PHP 8.3+

Symmetric encryption, derived keys, plaintext validation, and key rotation for Switon Framework.

Highlights

  • One encryption contract: CipherInterface keeps app code on one reversible boundary.
  • Plaintext validation: ValidatorInterface checks decrypted text before acceptance.
  • Rotation support: RotatingCipher keeps legacy ciphertext readable during migration windows.
  • Key generation: KeyCommand prints 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.