id 加密使用的是 [Hashids](http://hashids.org/),支持自定义字符串库和生成加密字符串的长度,使用对称加密,详细介绍请到Hashids官网查看 [http://hashids.org/](http://hashids.org/)
##配置
```
return [
// Hashids 的配置项
'length' => 8, // 加密字符串长度
'salt' => 'tpadmin', // 加密盐值
'alphabet' => '', // 字符仓库,不填写默认为扩展里的字符仓库
];
```
##方法
`HashidsHashids::instance($length = null, $salt = null, $alphabet = null)`
```
// id 加密
HashidsHashids::instance($length = null, $salt = null, $alphabet = null)->encode($id)
// id 解密
HashidsHashids::instance($length = null, $salt = null, $alphabet = null)->decode($hashedStr)
```
##参数
| 名称 | 类型 | 说明 |
| --- | --- | --- |
| length | int | 加密生成字符串长度 |
| salt | string | 加密盐值 |
| alphabet | string | 加密用到字符串的字符串库 |
##使用示例
```
$id = $this->request->post("id");
$hashids = HashidsHashids::instance(8, "tpadmin");
$encode_id = $hashids->encode($id); //加密
$decode_id = $hashids->decode($encode_id); //解密
return ajax_return_adv("操作成功", '', false, '', '', ['encode' => $encode_id, 'decode' => $decode_id]);
```
##助手函数
`hashids($length = null, $salt = null, $alphabet = null)`
```
hashids($length=null,$salt=null,$alphabet=null)->encode('你的字符串')
hashids($length=null,$salt=null,$alphabet=null)->decode('需要解密的字符串')
```