Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<Random\CryptoSafeEngineRandom\Engine\Secure::generate>
^RandomLast updated: Mon, 26 Oct 2026

The Random\Engine\Secure class

(PHP 8 >= 8.2.0)

Introduction

Generates cryptographically secure randomness using the operating system’s CSPRNG.

The randomness generated by this Random\Engine is suitable for all applications, including the generation of long-term secrets, such as encryption keys.

The Random\Engine\Secure engine is the recommended safe default choice, unless the application requires either reproducible sequences or very high performance.

Class synopsis

namespace Random\Engine;
final class Secure implements Random\CryptoSafeEngine {
/* Methods */
public function generate(): string
}

Table of Contents


<Random\CryptoSafeEngineRandom\Engine\Secure::generate>
^RandomLast updated: Mon, 26 Oct 2026