PHP code example of manojx / encrypter-bundle

1. Go to this page and download the library: Download manojx/encrypter-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

manojx / encrypter-bundle example snippets


use ManojX\EncrypterBundle\EncrypterInterface;

class YourService
{
    private EncrypterInterface $encrypter;

    public function __construct(EncrypterInterface $encrypter)
    {
        $this->encrypter = $encrypter;
    }

    public function encryptData(string $data): string
    {
        $salt = 'your-salt'; // Define your salt
        return $this->encrypter->encrypt($data, $salt);
    }

    public function decryptData(string $encryptedData): string
    {
        $salt = 'your-salt'; // Use the same salt for decryption
        return $this->encrypter->decrypt($encryptedData, $salt);
    }
}