定制 yzalis/id-obfuscator 二次开发

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

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

yzalis/id-obfuscator

最新稳定版本:1.0.0

Composer 安装命令:

composer require yzalis/id-obfuscator

包简介

An efficient reversible ID obfuscator originaly based on base 62 encoding.

README 文档

README

IdObfuscator is a library which helps you to hide your original IDs. The library helps you to encode and decode these IDs

SensioLabsInsight

Basic Usage

Instantiate the obfuscator

<?php

// create a new IdObfuscator instance
$idObfuscator = new \IdObfuscator\IdObfuscator();

Then you can encode your id and decode the generated hash.

$hash = $idObfuscator->encode(10); // $hash contain "A"
$id = $idObfuscator->decode('A'); // $id contain "10"

Here are some examples with the default set:

10 <=> 'A'
35 <=> 'Z'
36 <=> 'a'
61 <=> 'z'
62 <=> '10'
63 <=> '11'
134 <=> '2A'
3843 <=> 'zz'
3844 <=> '100'
144513 <=> 'bar'
160754 <=> 'foo'
238327 <=> 'zzz'
238328 <=> '1000'

Custom set

By default, the library use the following characters set to encode and decode. 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz

You can use the static method randomizeDefaultSet to shuffle the default set.

$myRandomSet = IdObfuscator::randomizeDefaultSet();

Or you can also use you own custom set.

$idObfuscator = new IdObfuscator('cusTOMS3t');
$idObfuscator->encode(1); // will return "c";
$idObfuscator->decode('t'); // will return "9";

Unit Tests

To run unit tests, you'll need cURL and a set of dependencies you can install using Composer:

curl -sS https://getcomposer.org/installer | php
php composer.phar install

Once installed, just launch the following command:

./vendor/bin/phpunit

You're done.

Credits

License

IdObfuscator is released under the MIT License. See the bundled LICENSE file for details.

统计信息

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

GitHub 信息

  • Stars: 4
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-05-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固