Showing posts with label random string. Show all posts
Showing posts with label random string. Show all posts

Monday, 12 September 2016

PHP Random String Generator

Small php snippet to generate a random string. Simple php function to generate random key/salt for encryption in php.

function randomString($length) {
    $allchars = array_merge( range('a','z'), range('A', 'Z'),range(0,9));
    $allchars = implode("", $allchars);
    return substr(str_shuffle($allchars), 0, $length);
}