Hashids将整数等数据类型转化为唯一字符串示例代码

代码语言:php

所属分类:加密解密

代码描述:Hashids将整数等数据类型转化为唯一字符串示例代码,不支持空值,支持数字,数组、字符串,可以设定不同的salt

代码标签: 数据 类型 化为 唯一 字符串 示例

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<?php

require("/data/wwwroot/default/lib/php/hashids/Math.php");
require("/data/wwwroot/default/lib/php/hashids/HashidsInterface.php");
require("/data/wwwroot/default/lib/php/hashids/Hashids.php");
//Quick Example
use Hashids\Hashids;
$hashids
= new Hashids('this is my salt');
$id
= $hashids->encode(1, 2, 3);
echo $id
."<br>";
$numbers
= $hashids->decode($id);
print_r
($numbers) ;


$hashids
= new Hashids();

$hashids
->encode(1);
//Note: Hashids requires either the BC Math or GMP extension in order to work.



$hash
.........完整代码请登录后点击上方下载按钮下载查看

网友评论0