Hashids is a library that generates short, unique, discontinuous identifiers from integers, and it supports many (really many) languages, including PHP.

$id = 123; $hashids = new Hashids\Hashids(); $hashID = $hashids->encode($id); $decodeResult = $hashids->decode($hashID); var_dump($hashID, $decodeResult); $hashID = $hashids->encode([1, 2, 3]); $decodeResult = $hashids->decode($hashID); var_dump($hashID, $decodeResult); $hashids = new hashids \ hashids (' I am salt '); $hashID = $hashids->encode($id); $decodeResult = $hashids->decode($hashID); var_dump($hashID, $decodeResult);Copy the code

Of course, preliminary understanding down, Yu Run also found many problems.

First, version 2.0 is no longer compatible with PHP <5.6.4 in composer configuration, but after testing, version 5.4 still works. Users with relevant requirements should not be deterred by this version limit.

Suffice it to say that there are quite a few problems, and users with relevant requirements can fork and modify the code themselves. Overall, Hashids are pretty good!

Github:github.com/ivanakimov/…

Composer: hashids/hashids

Programmer cluster Q: 74401592