mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/izyim.git
synced 2026-08-19 12:34:03 +00:00
24 lines
571 B
PHP
24 lines
571 B
PHP
<?php
|
|
|
|
namespace App\Classes;
|
|
|
|
|
|
use App\Classes\Modules\ControllerLogic\Exceptions\InternalServerErrorException;
|
|
|
|
final class common
|
|
{
|
|
|
|
/**
|
|
* @param int $length
|
|
* @return string
|
|
* @throws InternalServerErrorException
|
|
*/
|
|
public static function generateRandomHash(int $length = 10): string {
|
|
try {
|
|
return substr(bin2hex(random_bytes(ceil($length / 2))), 0, $length);
|
|
} catch (\Exception $exception){
|
|
throw new InternalServerErrorException('Failed to generate hash for user invitation');
|
|
}
|
|
|
|
}
|
|
} |