Download the PHP package mfonte/base62x without Composer

On this page you can find all versions of the php package mfonte/base62x. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?
mfonte/base62x
Rate from 1 - 5
Rated 2.33 based on 3 reviews

Informations about the package base62x

PHP Base62x Library

This library can be used to encode strings in Base62x format.

The reference implementation of Base62x has been taken by this repository: https://github.com/wadelau/Base62x

Stating the original author repository, Base62x is an alternative approach to Base 64 without symbols in output.

Base62x is an non-symbolic Base64 encoding scheme. It can be used safely in computer file systems, programming languages for data exchange, internet communication systems, etc, and it is an ideal substitute and successor of many variants of Base64 encoding scheme.

This repository is a wrapper around wadelau/Base62x repository, and is specifically crafted for PHP, with composer support.

It can be integrated into any framework, like Laravel, to enable Base62x support out of the box.

Latest Stable Version Total Downloads Build Status Scrutinizer Code Quality

Installation

Simple enough.

composer require mfonte/base62x

Required environment:

  1. PHP >= 7.2
  2. gzip module, for gzip compression support
  3. openssl module, for encryption support

Use cases

Base64 is notoriously bad to be used in GET strings. With this library, you can safely encode (and compress) and pass your data via GET parameters.

Another use case is when you have to communicate binary data from one server to another.

Many Apache modules (like Mod Security) will do some strange things, already seen in the wild, while passing raw binary data or complex jugglary in server2server communication.

Sure, you can use native base64_encode() and base64_decode() on both ends, but using this library not only you're encoding data, you can also compress and encrypt it on the go!.

Basic Usage

Usage is simple enough with a nice, expressive API:

Real use case scenario

A useful example of real use case scenario, that I've used on some projects, is passing json context data from an HTML page to an Ajax worker.

The data lifecycle from the frontend to the Ajax backend is fully encrypted, and doesn't break HTML apart, as Base62x strings are based on an alphabet that is compatible with embedding them in plain JS strings like I've shown in the provided example.

In the Ajax backend you can validate the token, collect the context data, and reply only if the setup is correct:

The library supports binary streams

It means that you can encode binary data, for example raw JPEGs or raw audio files.

The library supports compressed Base62x encoding!

While encoding in Base62x, you can also compress the payload.

This is expecially useful if you're planning on sending huge arrays or huge data via GET or POST requests, that you need to be sure it would not trigger errors from one machine to another, or from one url to another.

Important note: while decoding and decompressing, you don't need to specify the original compression algorithm, because this information is saved in a "magic string" at the beginning of the encoded payload. So, if you don't have control over another machine where your payloads can end, you don't have to worry to communicate the other side what type of compression you're actually using. The decode() method will automagically take care of that.

Available compression methods

  1. Gzip, encoding zlib, deflate, or gzip. Without any further instruction, the compress() method defaults to gzip/zlib
  2. Huffman via a dedicated PHP Huffman implementation. This compression method is currently not working. Please, do not use it in production environments.

These parameters can be passed to the compress() method like so:

Encryption

As of version 1.2 this library support encryption.

The encryption can be chained with compression.

Testing

Simply run composer install over this module's installation directory.

Then, run composer test to run all the tests.

Some tests may fail as testEncodingWithAllAvailableEncryptionAlgorithms performs a check over all available openssl_get_cipher_methods() installed on your environment. A possible example of failure is Encryption method "id-aes128-CCM" is either unsupported in your PHP installation or not a valid encryption algorithm.

TODO

Contributing

If you want to contribute to this project, please use php-cs-fixer to format your code to PSR standards and rules specified in the configuration file .php-cs-fixer.dist.php provided in this repository. Thank you!

Thank you's

A big thank you goes to wadelau [Wade Lau at ufqi.com] for implementing such an useful encoding pattern.


All versions of base62x with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mfonte/base62x contains the following files

Loading the files please wait ....