src/utils/helpers/SecurityHelper.php
public function generateRandomKey(int $length = 32): string
    {
        if ($length < 1) {
            throw new \RuntimeException('First parameter ($length) must be greater than 0');
        }

        // always use random_bytes() if it is available
        if (\function_exists('random_bytes')) {
            return \random_bytes($length);
        }
        throw new \RuntimeException('Function random_bytes not found');
    }
public function generateRandomKey(int $length = 32): string
    {
        if ($length < 1) {
            throw new \RuntimeException('First parameter ($length) must be greater than 0');
        }

        // always use random_bytes() if it is available
        if (\function_exists('random_bytes')) {
            return \random_bytes($length);
        }
        throw new \RuntimeException('Function random_bytes not found');
    }
public function generateRandomKey ( int $ length = 32 ) : string { if ( $ length < 1 ) { throw new \ RuntimeException ( 'First parameter ($length) must be greater than 0' ) ; } // always use random_bytes() if it is available if ( \ function_exists ( 'random_bytes' ) ) { return \ random_bytes ( $ length ) ; } throw new \ RuntimeException ( 'Function random_bytes not found' ) ; }
Generates specified number of random bytes.
Note that output may not be ASCII.

@see generateRandomString() if you need a string.

@param int $length the number of bytes to generate

@return string the generated random bytes
@throws \RuntimeException
Generates specified number of random bytes . Note that output may not be ASCII .