Str::random

Posted on November 25, 2016

The Str::random function generates a random string of the specified length.

Uses php 5.3.0 openssl_random_pseudo_bytes() function to produce random strings. If we want a string strong and sufficient for cryptography this is the method we need.

Example usage

$random = Str::random();
// 16 chars long random alphanumeric string
// Q7EPToH8la5M0SDh

$random = Str::random(3);
// 3 chars long random alphanumeric string
// w4G

Parameters

int $length

Return Value

string

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *