wemxo/encryption-bundle

Useful symfony bundle that offers the possibility to encrypt/decrypt sensitive data.

Installs: 15

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 0

Forks: 0

Open Issues: 0

Type:symfony-bundle

v1.0.3 2025-01-10 01:37 UTC

This package is auto-updated.

Last update: 2025-06-10 02:31:42 UTC


README

The encryption bundle is a symfony bundle that allow you to encrypt and decrypt sensitive data based on a given encryption key, sipher algorithm and digest method.

Usage

1- Configuration

# /config/packages/encryption.yaml
encryption:
    password:
        encryption_key: hO!}098iKko_hf
    email:
        encryption_key: '%my_key_parameter%'
        cypher_algorithm: aes128
        digest_method: md5

With this configuration, you will have access to a private service (instance of Wemxo\EncryptionBundle\Encryption\EncryptionInterface) in container named @wemxo.encryption.password with an alias $passwordEncryption.

2- Example

<?php

namespace App;

classe MyService {
    
    public function __construct(private EncryptionInterface $passwordEncryption, private EncryptionInterface $emailEncryption)
    {
    }
    
    public function testEncryptPassword(string $text): string
    {
        return $this->passwordEncryption->encrypt($text);
    }
    
    public function testDecryptPassword(string $text): string
    {
        return $this->passwordEncryption->decrypt($text);
    }
}