Created
February 3, 2019 16:35
-
-
Save eslavon/44bcf6d1f61eb26498588dbc0eea7421 to your computer and use it in GitHub Desktop.
func_random_key
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
<?php | |
function keyGenerate($leight) { | |
if (is_int($leight)) { | |
$array = array("1", "2", "3", "4", "5", "6", "7", "8", "9","0", | |
"A","B","D","E","F","G","H","I","J","K","L","M", | |
"N","O","P","Q","R","S","T","U","V","W","X","Y","Z"); | |
$count = count($array)-1; | |
$result = ""; | |
for ($i = 1; $i <= $leight; $i++) { | |
$random = mt_rand(0,$count); | |
$case = mt_rand(0,1); | |
if ($case == 0 ) { | |
$symbol = mb_strtolower($array[$random]); | |
} else { | |
$symbol = $array[$random]; | |
} | |
$result = $result.$symbol; | |
} | |
} else { | |
$result = "Введите длину генерируемого пароля!"; | |
} | |
return $result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment