Files
izyim/app/Classes/common.php
Omair Saleh 352b171d5c large commit
2019-06-03 22:48:42 +08:00

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');
}
}
}