This commit is contained in:
GitProtogen
2026-03-05 13:28:15 +01:00
parent 41b846f229
commit eb3e5eb043
+16 -1
View File
@@ -6,8 +6,23 @@ class TokenHandler
{
private static ?self $instance = null;
private static $tokens = [];
private static function uuid_v4(): string {
$data = random_bytes(16);
$data[6] = chr(ord($data[6]) & 0x0f | 0x40);
$data[8] = chr(ord($data[8]) & 0x3f | 0x80);
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
}
public static function getNewTokenForUser(string $username)
{
$uuid = sprintf(
'%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
mt_rand(0, 0xffff), mt_rand(0, 0xffff),
mt_rand(0, 0xffff),
mt_rand(0, 0x0fff) | 0x4000,
mt_rand(0, 0x3fff) | 0x8000,
mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
);
}
}