github: https://github.com/cdoco/hashids.phpc.git
一个可以生成类似于 YouTuBe 那种唯一字符串 ID 的功能,可以对用户隐藏数据库中的真正数字 ID
原来有纯 php 代码实现的一个功能,现在把它封装成了一个 php 扩展,性能比纯 php 的版本提升了百倍左右

使用也比较简单:
$hashids = new Hashids();
$hash = $hashids->encode(1, 2, 3, 4, 5); // ADf9h9i0sQ
$numbers = $hashids->decode($hash); // [1, 2, 3, 4, 5]
//你还可以直接使用静态方法
$hash = Hashids::encode(1, 2, 3, 4, 5); // ADf9h9i0sQ
$numbers = Hashids::decode($hash); // [1, 2, 3, 4, 5]
如果你项目中需要这种加密数字 id 的功能,可以试用下这个扩展 😆~
1
update 2018 年 4 月 12 日
什么原理
|
2
yimaneilicj 2018 年 4 月 12 日
mark
|
3
szopen 2018 年 4 月 13 日
对称加密数字,和没加密区别不大吧
|
4
jourdon 2018 年 4 月 19 日
uuid 嘛
|
5
xjroot 2018 年 5 月 1 日 via iPhone
这个看得很凶呢😊,可以可以,收藏了先。
|
8
Foolt 2018 年 5 月 29 日 via Android
|