mirror of
https://github.com/claradex/nativegallery.git
synced 2024-12-23 09:01:00 +03:00
28 lines
801 B
PHP
28 lines
801 B
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
|
|
class GenerateRandomStr
|
|
{
|
|
public static function init($length)
|
|
{
|
|
$characters = 'QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm';
|
|
$charactersLength = strlen($characters);
|
|
$randomString = '';
|
|
for ($i = 0; $i < $length; $i++) {
|
|
$randomString .= $characters[rand(0, $charactersLength - 1)];
|
|
}
|
|
return $randomString;
|
|
}
|
|
|
|
public static function gen_uuid() {
|
|
return 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 )
|
|
);
|
|
}
|
|
}
|