func_random_key
<?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