Kar 2025-04-02 19:16:22 +05:30
parent bb42b7c6db
commit af3da2e42a
1 changed files with 21 additions and 0 deletions

21
siliconid.php Normal file
View File

@ -0,0 +1,21 @@
<?php
function toBase62($num) {
$chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
$result = "";
while ($num > 0) {
$result = $chars[$num % 62] . $result;
$num = floor($num / 62);
}
return $result;
}
function generateID() {
$epochStart = strtotime('2020-01-01') * 1000;
$now = round(microtime(true) * 1000) - $epochStart;
$random = rand(0, 999); // 3-digit random number
$id = ($now * 1000) + $random; // Combine timestamp + randomness
return substr(str_pad(toBase62($id), 8, "0", STR_PAD_LEFT), 0, 8); // Ensure 8 chars
}
echo generateID(); // Example output: "4D7hF2L3"
?>