Created
July 6, 2018 09:27
-
-
Save racztiborzoltan/cbf32df79a17774e5f6c36a80a03d82f to your computer and use it in GitHub Desktop.
PHP: generate random string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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