Nette Documentation Preview

syntax
Random Strings Generator
************************

.[perex]
[api:Nette\Utils\Random] is a static class for generating cryptographically secure pseudo-random strings.

→ [Installation and requirements |@home#Installation]


generate(int $length=10, string $charlist=`'0-9a-z'`): string .[method]
-----------------------------------------------------------------------

Generates a random string of given length from characters specified in second argument. Supports intervals, such as `0-9` or `A-Z`.

```php
use Nette\Utils\Random;

Random::generate(10);       // '6zq3a1nl8n'
Random::generate(5, 'A-Z'); // 'HLKUR'
```

{{composer: nette/utils}}

Random Strings Generator

Nette\Utils\Random is a static class for generating cryptographically secure pseudo-random strings.

Installation and requirements

generate(int $length=10, string $charlist=`'0-9a-z'`)string

Generates a random string of given length from characters specified in second argument. Supports intervals, such as 0-9 or A-Z.

use Nette\Utils\Random;

Random::generate(10);       // '6zq3a1nl8n'
Random::generate(5, 'A-Z'); // 'HLKUR'