---
title: "Feature: #73050 - Add a CSPRNG API"
manual: "TYPO3 Core Changelog"
version: "main"
permalink: "https://docs.typo3.org/permalink/changelog:feature-73050"
source: "Changelog/8.0/Feature-73050-AddACSPRNGAPI.rst"
modified: "2026-09-15T10:46:36+00:00"
---

# Feature: #73050 - Add a CSPRNG API

See [forge#73050](https://forge.typo3.org/issues/73050)

## Description

A new cryptographically secure pseudo-random number generator (CSPRNG) has been
introduced in TYPO3 core. It takes advantage of the new CSPRNG functions in PHP 7.

## API overview

The API resides in the class `\TYPO3\CMS\Core\Crypto\Random`. It provides several
methods. Here is a brief overview of the interface:

```php
class Random {
    /**
     * Generates cryptographic secure pseudo-random bytes
     */
    public function generateRandomBytes($length);

    /**
     * Generates cryptographic secure pseudo-random integers
     */
    public function generateRandomInteger($min, $max);

    /**
     * Generates cryptographic secure pseudo-random hex string
     */
    public function generateRandomHexString($length);
}
```

### Example

```php
use \TYPO3\CMS\Core\Crypto\Random;
use \TYPO3\CMS\Core\Utility\GeneralUtility;

// Retrieving random bytes
$someRandomString = GeneralUtility::makeInstance(Random::class)->generateRandomBytes(64);

// Rolling the dice..
$tossedValue = GeneralUtility::makeInstance(Random::class)->generateRandomInteger(1, 6);
```

## Impact

None, you can start to use the CSPRNG in your code by now.
