Skip to content

Latest commit

 

History

History
46 lines (30 loc) · 1.02 KB

File metadata and controls

46 lines (30 loc) · 1.02 KB

MultiEncoder

Package for managing multi-step encoding and decoding of strings/objects.

Usage

use o6web\MultiEncoder\Encoder;
use o6web\MultiEncoder\Step;

// Define the encoding steps
$encode = [
    // Steps can be existing functions or callable
	new Step('strrev'),
	new Step('base64_encode'),
];

// Define the decoding steps
$decode = [
	new Step('base64_decode'),
	new Step('strrev'),
];

$multiEncoder = new Translator($encode, $decode);

$data = 'This is a string';

$encoded_data = $multiEncoder->encode($data); // Z25pcnRzIGEgc2kgc2loVA==

$decoded_data = $multiEncoder->decode($encoded_data); // This is a string

Installation

  1. Add a dependency on o6web/multiencoder to your composer.json file if you use Composer to manage the dependencies of your project:
composer require o6web/multiencoder

Although it's recommended to use Composer, you can actually include the file(s) any way you want.

License

MultiEncoder is MIT licensed.