Skip to content

Instantly share code, notes, and snippets.

@racztiborzoltan
Created July 6, 2018 09:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save racztiborzoltan/cbf32df79a17774e5f6c36a80a03d82f to your computer and use it in GitHub Desktop.
Save racztiborzoltan/cbf32df79a17774e5f6c36a80a03d82f to your computer and use it in GitHub Desktop.
PHP: generate random string
/**
* Generate random string
*
* Strong password definition on strongpasswordgenerator.com
* - at least 15 characters
* - uppercase and lowercase letters
* - numbers
* - symbols, such as ` ! " ? $ ? % ^ & * ( ) _ - + = { [ } ] : ; @ ' ~ # | \ < , > . ? /
*
* @param number $length
* @param string $abc
* @return string
*/
function generateRandomString($length = 20, $abc = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`!"?$?%^&*()_-+={[}]:;@\'~#|\<,>.?/')
{
return substr(str_shuffle(str_repeat($abc, $length)), 0, $length);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment