File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed
Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,10 @@ echo id_decode('m_Dl9'); //包含无效字符,抛出错误
3636echo id_decode('nlK8GhRW'); //校验错误,抛出错误
3737
3838```
39+ 和[ hashids/hashids] ( https://github.com/ivanakimov/hashids.php ) 不同的是` hashids ` 提供多个数字或包含多个数字的数组加密成一个字符串,
40+ 解密时以数组形式返回,这在实际应用中并不常见,反而给使用带来一定麻烦,
41+ 而此包对此进行了一些处理,不提供多个数字或多个数字数组的加密,解密时直接返回解密后的数字。
42+
3943## Laravel深度应用
4044### 加密
4145有2种方法实现自动加密
Original file line number Diff line number Diff line change 33use Hashids \Hashids ;
44
55if (! function_exists ('id_encode ' )) {
6+
67 /**
7- * 加密正整数
8- *
98 * @param $int
10- * @return string | null
9+ * @return string
10+ * @throws HashidException
1111 */
1212 function id_encode ($ int )
1313 {
@@ -20,11 +20,11 @@ function id_encode($int)
2020}
2121
2222if (! function_exists ('id_decode ' )) {
23+
2324 /**
24- * 对加密后的字符串解密
25- *
2625 * @param $str
27- * @return Number | null
26+ * @return integer
27+ * @throws HashidException
2828 */
2929 function id_decode ($ str )
3030 {
You can’t perform that action at this time.
0 commit comments