How to encrypt laravel 5.2 URL or Routes?

后端 未结 7 819
情歌与酒
情歌与酒 2020-12-19 10:51

I need to encrypt routes in this URL? Because I do not want user to access URL by changing the item id. For example, user can change /items/1234 to /item/5678. Although item

相关标签:
7条回答
  • 2020-12-19 11:19

    You require encrypt URL ID/Any URL param and this is called id obfuscation. You can do it with hashids library. it converts an integer like 347 to yr8 and back again.

    Include this library:

    composer require hashids/hashids
    

    You can get all other easy stuff from Easy id obfuscation with Laravel 5

    This will help you to encrypt URL id:

    http://example.com/users/123
    

    TO

    http://example.com/users/Mj3
    

    Hope this will help you well!

    0 讨论(0)
提交回复
热议问题