Need to hide the ID in the foreground, you can consider using this product, the generated ID is relatively tall, compared to such as Youtube, Youku, Weibo, such as the ID name, such as: Xnjkxmtc0mdq4
Official website: http://hashids.org/php/
Laravel 5 pack: Https://github.com/vinkla/hashids
Simple and practical examples 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 complete, and there are Composer packages, Laravel 4, Laravel 5 package, CodeIgniter Spark, Symfony Bundle, Kohana module, Wordpress Plugin, CakePHP component, Silex package, Craft plugin Featu and more. Links can be found on the official website
also supports JavaScript, Ruby, Python, Java, Scala, PHP, Perl, Swift, Objective-c, C, c++11, Go, Lua, Elixir, ColdFusion, Groovy, K Otlin, Nim, VBA, Coffeescript and for node. JS &. NET language
Laravel 5 Use
The use is relatively simple, and the documentation has been more detailed.
After the package is installed, follow the instructions in the documentation
PHP Artisan Vendor:publish
Action to generate the configuration file, Profile path: config\hashids.php:
' Alphabet ' = ' your-alphabet-string '
Configuration item is what character you intend to let in the encrypted string, I use a-Z, A-Z, 0-9, and later found that it seems to be related to the character sequence, generated random string case and the number distribution is not very uniform, the use of PHP shuffle () function scrambled order generated a new set of Alphabet, and then it looks bigger.
Examples of Use:
You can alias this in Config/app.php.use Vinkla\hashids\facades\hashids; Hashids::encode (4815162342);//We do here-how Easy is that, it just works! Hashids::d ecode (' Doyouthinkthatsairyourebreathingnow ');//This example was simple and there be far more methods available .