0712-2888027 189-8648-0214
微信公众号

孝感风信网络科技有限公司微信公众号

当前位置:主页 > 技术支持 > PHP > Laravel Hashids一款不错的哈希数据ID解决方案

Laravel Hashids一款不错的哈希数据ID解决方案

时间:2024-04-25来源:风信官网 点击: 1570次
在Laravel中我们使用composer进行安装 vinkla/hashids开源库,可以将字符串ID转化为数字ID。

我们使用composer进行安装,最新的laravel-hashids 需要Laravel 5.6版本以上支持。

$ composer require vinkla/hashids

扩展包配置

$ php artisan vendor:publish

GitHUB项目地址:https://github.com/vinkla/laravel-hashids

使用示例代码:

使用use引入Hashids

// You can alias this in config/app.php.
use Vinkla\Hashids\Facades\Hashids;

对字符串进行加密
Hashids::encode(4815162342);
// We're done here - how easy was that, it just works!

对字符串进行解密
Hashids::decode('doyouthinkthatsairyourebreathingnow');
// This example is simple and there are far more methods available.
热门关键词: Laravel Hashids 哈希数据ID
栏目列表
推荐内容
热点内容
展开