Created
April 28, 2011 14:20
-
-
Save atbradley/946439 to your computer and use it in GitHub Desktop.
Generate a random-enough string. Maybe useful for passwords or for the encryption seed required in some frameworks' configuration file.
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
function randstr($len = 8) { | |
$src = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; | |
$src = $src.$src.$src.$src.$src; | |
return substr(str_shuffle($src), 0, $len); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment