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

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.

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容