Last active
June 24, 2017 09:54
-
-
Save kidker/c47fd83d6e22dcb9916b6462e6c7ec47 to your computer and use it in GitHub Desktop.
PHP/JS Generate MySQL password [length=32]
This file contains hidden or 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
function generateRandomString(length) { | |
var characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()-_+=;:,./?\\|`~[]{}'; | |
var randomString = ''; | |
for (var i = 0; i < length; i++) { | |
randomString += characters[Math.floor(Math.random() * (characters.length - 1))]; | |
} | |
return randomString; | |
} |
This file contains hidden or 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
function generateRandomString($length = 32) { | |
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()-_+=;:,./?\\|`~[]{}'; | |
$randomString = ''; | |
for ($i = 0; $i < $length; $i++) { | |
$randomString .= $characters[rand(0, strlen($characters) - 1)]; | |
} | |
return $randomString; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment