当前位置: 首页 > 工具软件 > hashids > 使用案例 >

hashids php 如何使用,PHP Hashids 方法

澹台正业
2023-12-01

/**

* 库:https://github.com/ivanakimov/hashids.php

* 生成唯一字符串

* @param $str

* @param string $salt

* @param string $length

* @param string $alphabet

* @return false|string

*/

public static function hashids($str, $salt = '', $length = '', $alphabet = '')

{

$hashids = new Hashids($salt, $length, $alphabet);

return $hashids->encode($str);

}

/**

* hashids解析

* @param $str

* @param string $salt

* @param string $length

* @param string $alphabet

* @return false|string

*/

public static function decodehashids($str, $salt = '', $length = '', $alphabet = '')

{

$hashids = new Hashids($salt, $length, $alphabet);

return $hashids->decode($str);

}

 类似资料: