Hashids is an open source library that generates short, unique, unclassified, YouTube-like identifiers from one or many numbers. You can think of it as an algorithm for obfuscating numbers .
It converts numbers like 347 into strings such as "yr8", or an array like [27, 986] into "3kTMd". You can also decode these identifiers. This is useful for combining several parameters into one or simply using them as short UIDs.
Use it when you do not want to disclose your ids database to the user.
It allows you to customize the alphabet, as well as salt, so the identifiers are unique only to you.
Incremental input is distorted to remain irrefutable.
There are no collisions, because the method is based on converting an integer to hexadecimal.
It was written with the goal of placing the generated identifiers in visible places, such as URLs. Thus, the algorithm avoids generating the most common English curse words.
Code example
$hashids = new Hashids(); $id = $hashids->encode(1, 2, 3); // o2fXhV $numbers = $hashids->decode($id); // [1, 2, 3]
Demis Palma ツ
source share