public static function randomString(int $length): string
    {
        try {
            $rand = bin2hex(random_bytes($length));
            // bytes_length = length * 2
            $rand = substr($rand, 0, $length);
        } catch (\Exception $ce) {
            $rand = Str::randomLatinNumeric($length);
        }

        return $rand;
    }
public static function randomString(int $length): string
    {
        try {
            $rand = bin2hex(random_bytes($length));
            // bytes_length = length * 2
            $rand = substr($rand, 0, $length);
        } catch (\Exception $ce) {
            $rand = Str::randomLatinNumeric($length);
        }

        return $rand;
    }
public static function randomString ( int $ length ) : string { try { $ rand = bin2hex ( random_bytes ( $ length ) ) ; // bytes_length = length * 2 $ rand = substr ( $ rand , 0 , $ length ) ; } catch ( \ Exception $ ce ) { $ rand = Str :: randomLatinNumeric ( $ length ) ; } return $ rand ; }
Generate random string with numbers from secure function random_bytes
@param int $length
@return string
Generate random string with numbers from secure function random_bytes