jocic/encoders

Encoders is a creatively named PHP library containing various binary-to-text encoding implementations.

1.0.0 2019-01-17 23:47 UTC

This package is auto-updated.

Last update: 2024-04-19 09:50:35 UTC


README

Build Status Coverage Status Codacy Badge Latest Stable Version License

Encoders is a creatively named PHP library containing various binary-to-text encoding implementations.

I basically wrote a Base 32 implementation for my other project, Google Authenticator which you can find on GitHub, and thought to myself, hey...why not create an entire library featuring binary-to-text encoders, that's kind of fun? So here it is. A filler project, for fun.

Project Image

Following specifications are referenced:

  • RFC 4648 - Base 16, Base 32 & Base 64 Data Encodings

Buy Me Coffee

Song of the project: Albert Veli - Write in C

Versioning Scheme

I use a 3-digit Semantic Versioning identifier, for example 1.0.2. These digits have the following meaning:

  • The first digit (1) specifies the MAJOR version number.
  • The second digit (0) specifies the MINOR version number.
  • The third digit (2) specifies the PATCH version number.

Complete documentation can be found by following the link above.

Examples

Using encoders from the library is extremely simple but, just in case you are getting started with PHP programming language, I've prepared several examples to help you on your journey. You simply need to instantiate an object of your desired encoder and use the "encode" or "decode" methods respectively.

Base Encoding & Decoding

Only Base 16 and Base 32 are currently supported.

Base 16

$encoder = new Jocic\Encoders\Base\Base16();

echo $encoder->encode("foo");
echo $encoder->decode("666F6F");

Base 32

$encoder = new Jocic\Encoders\Base\Base32();

echo $encoder->encode("foo");
echo $encoder->decode("MZXW6===");

Base 64

$encoder = new Jocic\Encoders\Base\Base64();

echo $encoder->encode("foo");
echo $encoder->decode("Zm9v");

Installation

There's two ways you can add Encoders library to your project:

  • Copying files from the "source" directory to your project and requiring the "Autoload.php" script
  • Via Composer, by executing the command below
composer require jocic/encoders 1.0.0

Tests

Following unit tests are available:

  • Essentials - Tests for library's essentials ex. Autoloader, etc.
  • Base - Tests for Base encoders - Base 16, Base 32 & Base 64.

You can execute them easily from the terminal like in the example below.

bash ./scripts/phpunit.sh --testsuite essentials
bash ./scripts/phpunit.sh --testsuite base

Please don’t forget to install necessary dependencies before attempting to do the God's work above. They may be important.

bash ./scripts/composer.sh install

Contribution

Please review the following documents if you are planning to contribute to the project:

Support

Please don't hesitate to contact me if you have any questions, ideas, or concerns.

My Twitter account is: @jocic_91

My support E-Mail address is: support@djordjejocic.com

Copyright & License

Copyright (C) 2018 Đorđe Jocić

Licensed under the MIT license.