If you need to hide the ID at the front end, you can consider using this product, the generated id is relatively tall, more like Youtube, Youku, Weibo and other id names, such as: XNjkxMTc0MDQ4 Laravel 5 package: https://github.com/vinkla/hashids
Simple and practical example in PHP:
$hashids = new Hashids\Hashids('this is my salt');$id = $hashids->encode(1, 2, 3);$numbers = $hashids->decode($id);
Of course, the package is comprehensive, including Composer package, Laravel 4 package, Laravel 5 package, CodeIgniter spark, Symfony bundle, Kohana module, Wordpress plugin, CakePHP component, Silex package, and Craft plugin featu. You can find the link on the official website.
It also supports JavaScript, Ruby, Python, Java, Scala, PHP, Perl, Swift, Objective-C, C, C ++ 11, Go, Lua, Elixir, ColdFusion, Groovy, kotlin, Nim, VBA, CoffeeScript and for Node. js &. NET language
Use Laravel 5
It is easy to use and detailed in the documentation.
Run
php artisan vendor:publish
Operation to generate the configuration file. the configuration file path is config \ hashids. php:
'alphabet'=> 'your-alphabet-string'
The configuration item is what character you intend to display in the encrypted string. I used A-Z, a-z, 0-9, and later found that it seems to be related to the character sequence, the generated random string is not evenly case-sensitive and numbers. the shuffle () function of PHP is used to disrupt the order and generate a new set of alphabet. then it looks very tall.
Example:
// 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.