Skip to content

The easiest tool to encrypt/decrypt strings and arrays in PHP

Notifications You must be signed in to change notification settings

TurboLabIt/php-encryptor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

php-encryptor

A single, zero-config service with encrypt() and decrypt() methods to safely share or expose confidential data

📦 1. Install it with composer

symfony composer require turbolabit/php-encryptor:dev-main

🔁 2. Symfony usage

<?php
use TurboLabIt\Encryptor\Encryptor;


class Property
{
    protected string $bookingToken = '12345678';
    
    public function __construct(protected Encryptor $encryptor)
    {}
    
    
    public function getBookingData() : string
    {
        $arrData = [
            "name"          => 'aabbcc',
            "bookingToken"  => $this->bookingToken;
        ]    

        return $this->encryptor->encrypt($arrData);
    }
    
    
    public function decodeBookingData(string $text) : array
    {
        return $this->encryptor->decrypt($text);
    }
}

See: Usage

3. ⚙️ Symfony custom configuration (optional)

# config/services.yaml
TurboLabIt\Encryptor\Encryptor:
  arguments:
    $secretKey: '%env(APP_SECRET)%'

See: services.yaml

🧪 Test it

git clone [email protected]:TurboLabIt/php-encryptor.git
cd php-encryptor
bash script/symfony-bundle-tester.sh

About

The easiest tool to encrypt/decrypt strings and arrays in PHP

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published