Bootstrap 5 continued + bugfixes
This commit is contained in:
@ -102,4 +102,18 @@ function generateRandomString( $length = 10 ) {
|
||||
$randomString .= $characters[random_int(0, $charactersLength - 1)];
|
||||
}
|
||||
return $randomString;
|
||||
}
|
||||
|
||||
function generateUuidV4(): string {
|
||||
// Generate 16 random bytes
|
||||
$data = random_bytes(16);
|
||||
|
||||
// Set the version to 4 -> random (bits 12-15 of time_hi_and_version)
|
||||
$data[6] = chr((ord($data[6]) & 0x0f) | 0x40);
|
||||
|
||||
// Set the variant to RFC 4122 -> (bits 6-7 of clock_seq_hi_and_reserved)
|
||||
$data[8] = chr((ord($data[8]) & 0x3f) | 0x80);
|
||||
|
||||
// Convert to hexadecimal and format as a UUID
|
||||
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
|
||||
}
|
Reference in New Issue
Block a user