欢迎您光临自学哈网,只为分享网络知识教程,供大家学习参考!

「自学哈网」Laravel Hashids的哈希数据ID有什么解决方案

作者 : 自学哈 本文共546个字,预计阅读时间需要2分钟 2023-04-15 共148人阅读
也想出现在这里? 联系我们

Laravel Hashids的哈希数据ID有什么解决方案

 

在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.

本站声明:
本站所有资源来源于网络,分享目的仅供大家学习和交流!如若本站内容侵犯了原著者的合法权益,可联系邮箱976157886@qq.com进行删除。
自学哈专注于免费提供最新的分享知识、网络教程、网络技术的资源分享平台,好资源不私藏,大家一起分享!

自学哈网 » 「自学哈网」Laravel Hashids的哈希数据ID有什么解决方案
也想出现在这里? 联系我们
© 2022 Theme by - 自学哈网 & WordPress Theme. All rights reserved 浙ICP备2022016594号