定制 mindplay/keypack 二次开发

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

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

mindplay/keypack

Composer 安装命令:

composer require mindplay/keypack

包简介

Pack/unpack integer and GUID keys to shorter strings

README 文档

README

This library packs integer, UUID and GUID keys to shorter strings, e.g. for use in user-facing URLs.

PHP Version Build Status

Usage

Three classes, IntPacker, UUIDPacker and GUIDPacker are provided, each capable of packing/unpacking a particular type of ID. Each class has essentially the same interface, but accepting/returning different types of keys.

Here's an example of packing/unpacking a UUID to a shorter string:

$packer = new UUIDPacker();

echo $packer->pack("7eb6de1e-65ef-4fb7-baff-c0732c1c4614"); // => "py6dWN6dgKR8cGVz73zDiT"

echo $packer->unpack("py6dWN6dgKR8cGVz73zDiT"); // => "7eb6de1e-65ef-4fb7-baff-c0732c1c4614" 

You can pack keys using different notations. The default is legible, which produces human-readable and reasonably short keys - see here for more options.

You can also add redundancy to packed keys, to prevent typos make it harder to guess a packed key.

Here's an example packing an integer key to base64 with 4 bytes of redundancy:

$packer = new IntPacker('base64');

$packer->setRedundancy(4, 'super secret salt');

echo $packer->pack(123456); // => "7yg6HR"

echo $packer->unpack("7yg6HR"); // => (int) 123456

Note that unpack() will return null if the redundancy check fails.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-08-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固