承接 ierusalim/baseconvert 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ierusalim/baseconvert

Composer 安装命令:

composer require ierusalim/baseconvert

包简介

Convertation from/to any user-defined base-chars-string throught decimal representation of arbitrary precision

README 文档

README

Build Status

Convertation from/to any user-defined base-chars-string throught decimal representation of arbitrary precision.

Installation

File BaseConvert.php may be use independent.

For composer:

composer require ierusalim/baseconvert

Usage BaseConvert

Create instance of BaseConvert class and define own base-characters string (if need).

No need to define new alphabet for use hex/binary/base58(bitcoin compatible).

use ierusalim\BaseConvert;

$bc = new BaseConvert;

$hex = "43786437856abcdef";
$b58 = $bc->hextobase58($hex);

echo "$hex => base58: $b58";

Functions

  • -> dectohex($dec) -- Convert from decimal (012345679-base) to hex (0123456789abcdef-base)
  • -> hextodec($hex) -- Convert from hex (0123456789abcdef-base) to decimal (012345679-base)
  • -> dectobits($dec) -- Convert from decimal (012345679-base) to string of bits (01-base)
  • -> bitstodec($bits) -- Convert from bits to decimal representation of arbitrary precision
  • -> hextobits($hex) -- Convert from hex (0123456789abcdef-base) to bits string (01-base)
  • -> bitstohex($bits) -- Convert from bits (01-base) to hex (0123456789abcdef-base)
  • -> dectobase58($dec) -- Convert from decimal (012345679-base) to base58
  • -> hextobase58($hex) -- Convert from hex (0123456789abcdef-base) to base58
  • -> base58tohex($b58) -- Convert from base58 to hex (0123456789abcdef-base)
  • -> basex_decode($data, $base_id) -- Convert from arbitrary base to decimal
  • -> basex_encode($dec, $base_id) -- Convert from decimal to arbitrary base

Usage vc85

vc85 is a one of many base85-algorithms, like ascii85, z85, etc.

Encoding vc85 has the following features:

  • Each character is visually unique and easily recognizable: 0123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyzзгджилпфцчшюяБГДЖИЛПФЦЧШЮЯ
  • Encoded result does not contain special characters;
  • encoding and decoding runs fast.
use ierusalim\BaseConvert;

$bc = new vc85();

$str = "One day I'm gonna fly away One day when heavens calls my name";
$enc = $bc->vc85_encode($str);

echo "result: $enc \n";

// result: RkШжцYNQлAPjhWЮZLжz9XJZEЯeФ3nVXTБЮДbgГЧ3XTБЯVZnЯ67ZnЮtЦYrЯpJXФШGБd0BUdAbЮu81G

$back = $bc->vc85_decode($enc);

echo ($str === $back) ? "OK" : "Fail";

Functions vc85

  • -> vc85_encode($str) -- Convert from binary data to vc85
  • -> vc85_decode($str) -- Convert from vc85 to binary data

Functions base6400

  • -> base6400_encode($str) -- Convert from binary to base6400
  • -> base6400_decode($str) -- Convert from base6400 to binary
  • -> explodeToUnicode($str) -- Convert string from utf-8 to Unicode-array
  • -> implodeUnicode($arr) -- Convert Unicode-array to utf-8 string

Bases (pre-defined base_id)

    public $bases = [
        2 => '01',
        3 => '012',
        4 => '0123',
        8 => '01234567',
        10 => '0123456789',
        16 => '0123456789abcdef',
        58 => '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz',
    ];

统计信息

  • 总下载量: 40
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2018-02-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固