mirror of
https://github.com/WerySkok/nativegallery.git
synced 2024-11-15 11:39:13 +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 )
|
|
);
|
|
}
|
|
}
|