30 lines
897 B
Markdown
30 lines
897 B
Markdown
SiliconID - a better/replacement of UID
|
|
Capablity: Uniqueness, Limited Length along with Sortability
|
|
|
|
i used to use a function using php to generate randome string,
|
|
intent to use replacement of UID, so i can use this on DOS
|
|
system (max 8 char constrain)
|
|
|
|
i needed Uniqueness, Limited Length along with Sortability.
|
|
Options i had
|
|
on dos
|
|
@echo off
|
|
set /a num=%random%%%100000000
|
|
echo %num%
|
|
on linux/bsd
|
|
cat /proc/sys/kernel/random/uuid | cut -c1-8
|
|
date +%s%N | sha256sum | base64 | head -c 8
|
|
|
|
|
|
lets re-implement SiliconID maintaining Uniqueness to reduce collisions
|
|
having Limited Length along with Sortability
|
|
|
|
keeping in mind:
|
|
1. Custom Epoch is supported by every modern programming Language.
|
|
2. Can start with 2020
|
|
3. Timestamp with mili second
|
|
4. [timestamp (10 digits)] + [random number (5 digits)] = 15-digit decimal
|
|
5. Encoding 14-digit decimal into Base-62 gives exactly 8 chars
|
|
|
|
|