1. Go to this page and download the library: Download eloquent/endec 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/ */
use Eloquent\Endec\Base32\Base32;
$codec = new Base32;
$encodeStream = $codec->createEncodeStream();
$decodeStream = $codec->createDecodeStream();
$encoded = '';
$encodeStream->on(
'data',
function ($data, $stream) use (&$encoded) {
$encoded .= $data;
}
);
$decoded = '';
$decodeStream->on(
'data',
function ($data, $stream) use (&$decoded) {
$decoded .= $data;
}
);
$encodeStream->pipe($decodeStream);
$encodeStream->write('fo');
$encodeStream->write('ob');
$encodeStream->end('ar');
echo $encoded; // outputs 'MZXW6YTBOI======'
echo $decoded; // outputs 'foobar'
use Eloquent\Endec\Base32\Base32;
use Eloquent\Endec\Exception\EncodingExceptionInterface;
$codec = new Base32;
try {
$codec->decode('!!!!!!!!');
} catch (EncodingExceptionInterface $e) {
echo 'Unable to decode';
}
use Eloquent\Endec\Endec;
Endec::registerFilters();
$path = '/path/to/file';
$stream = fopen($path, 'wb');
stream_filter_append($stream, 'endec.base32-decode');
if (!fwrite($stream, '!!!!!!!!')) {
echo 'Unable to decode';
}
fclose($stream);
use Eloquent\Endec\Base32\Base32;
$codec = new Base32;
$decodeStream = $codec->createDecodeStream();
$decodeStream->on(
'error',
function ($error, $stream) {
echo 'Unable to decode';
}
);
$decodeStream->end('!!!!!!!!');
use Eloquent\Confetti\TransformInterface;
class Rot13Transform implements TransformInterface
{
public function transform($data, &$context, $isEnd = false)
{
return array(str_rot13($data), strlen($data));
}
}
use Eloquent\Endec\Codec;
use Eloquent\Endec\Decoder;
use Eloquent\Endec\Encoder;
$transform = new Rot13Transform;
$encoder = new Encoder($transform);
echo $encoder->encode('foobar'); // outputs 'sbbone'
$decoder = new Decoder($transform);
echo $decoder->decode('foobar'); // outputs 'sbbone'
$codec = new Codec($transform, $transform);
echo $codec->decode($codec->encode('foobar')); // outputs 'foobar'
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.