Skip to content

switon-php/crypto

Repository files navigation

Switon Crypto Package

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.

About

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

Topics

Resources

License

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages