i
This commit is contained in:
@@ -6,8 +6,23 @@ class TokenHandler
|
|||||||
{
|
{
|
||||||
private static ?self $instance = null;
|
private static ?self $instance = null;
|
||||||
private static $tokens = [];
|
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)
|
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)
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user