OpenSSL encryption driver --- encrypts and decrypts data using AES-256-GCM with authenticated encryption.
composer require marko/encryption-opensslRequires the ext-openssl PHP extension. Automatically installs marko/encryption.
use Marko\Encryption\Contracts\EncryptorInterface;
class SecureStorage
{
public function __construct(
private EncryptorInterface $encryptor,
) {}
public function store(string $sensitiveData): string
{
return $this->encryptor->encrypt($sensitiveData);
}
public function retrieve(string $encrypted): string
{
return $this->encryptor->decrypt($encrypted);
}
}Full usage, API reference, and examples: marko/encryption-openssl