定制 xobotyi/basen 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

xobotyi/basen

最新稳定版本:v1.0.0

Composer 安装命令:

composer require xobotyi/basen

包简介

Text and integers encoding utilities for PHP with no extensions dependencies. Base32, Base58, Base64 and much more!

README 文档

README

License PHP 7 ready Build Status Codacy Grade Codacy Coverage Latest Stable Version Total Downloads

About

PHP is a great language but unfortunately provides us with only one text encoding (base64) which even not URL safe. And there are no straight way to change its alphabet.
BaseN solves that problem and implements common binary-to-text algorithm for encodings whose alphabet fully covers number of bits that corresponds its length. And rough algorithm which will encode each byte separately, it is less compact but guarantee the encoding with given alphabet.
Furthermore it gives you methods to encode and decode integers themselves instead of their text representation.

Requirements

Installation

Install with composer

composer require xobotyi/basen

Usage

use xobotyi\basen\BaseN;
use xobotyi\basen\Base58;

// use it for something usual
$base8 = new BaseN('01234567', false, false, false);
echo $base8->encode(16) . "\n"; // 142330
echo $base8->encodeInt(16) . "\n"; // 20

// or create your own encoder with own alphabet if needed
$myOwnEncoder = new BaseN('a123d8e4fiwnmqkl', false, true, true);
echo $myOwnEncoder->encode(16) . "\n"; // 313e
echo $myOwnEncoder->encodeInt(16) . "\n"; // 1a

// predefined encoder
echo Base58::encode(16) . "\n"; // 3hC
// or, with alternative alphabet
echo Base58::encode(16, Base58::ALPHABET_RIPPLE) . "\n"; // hkD
echo Base58::encodeInt(16) . "\n"; // G

Builtin encodings

BaseN provides few classes implementing most popular encodings:

统计信息

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

GitHub 信息

  • Stars: 12
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-06-14