deemru/abcode

ABC (alphabet) encode/decode

1.0.6 2023-04-10 15:28 UTC

This package is auto-updated.

Last update: 2024-12-10 18:59:57 UTC


README

packagist php-v GitHub codacy license

ABCode is a universal (single byte per character) alphabet converter for PHP.

  • Built in base58
  • Convert strings to your alphabet
  • Convert between alphabets

Usage

// Built in base58
$data = ABCode::base58()->encode( 'Hello, world!' );
if( $data !== '72k1xXWG59wUsYv7h2' )
    exit( 1 );

// Convert strings to your alphabet
$abcode = new ABCode( 'my_ABC' );
$data = $abcode->encode( $data );
if( $data !== 'BAAy_Cmm_BA_AC_BCA_A_ymymCCmyyBBABBACCyBm___mA_BAm_yA__' )
    exit( 1 );

// Convert between alphabets
$abcode = new ABCode( 'my_ABC', 'another_ABC-123' );
$data = $abcode->decode( $data );
if( $data !== 'otah2_en3_o22ABhhrroA1eCAC3ronBn3t2-o' )
    exit( 1 );

Requirements

Installation

Require through Composer:

{
    "require": {
        "deemru/abcode": "1.0.*"
    }
}