mirror of
https://github.com/NamelessMC/Nameless
synced 2026-08-18 06:29:04 -04:00
* Create StyleCI config file * Disable `phpdoc_separation` * Apply fixes from StyleCI (#3476) Co-authored-by: StyleCI Bot <bot@styleci.io> * style: styleci fixes --------- Co-authored-by: StyleCI Bot <bot@styleci.io> Co-authored-by: Sam <samerton@users.noreply.github.com>
23 lines
528 B
PHP
23 lines
528 B
PHP
<?php
|
|
|
|
/**
|
|
* Secure random token generation.
|
|
*
|
|
* @package NamelessMC\Core
|
|
* @author Derkades
|
|
* @version 2.0.0-pr13
|
|
* @license MIT
|
|
*/
|
|
class SecureRandom
|
|
{
|
|
/**
|
|
* Generate a unique alphanumeric string.
|
|
*
|
|
* @throws Exception If an appropriate source of randomness cannot be found.
|
|
* @return string Generated string.
|
|
*/
|
|
public static function alphanumeric(int $num_bytes = 32): string
|
|
{
|
|
return preg_replace('/(\+|\/|\=)*/', '', base64_encode(random_bytes($num_bytes)));
|
|
}
|
|
}
|