PHP;">
public function createRandCode($string) {
$code = '';
$hex_code = '1qaz2wsx3edc4rfv5t-gb6yhn7ujm8ik9ol0p_';
$now = microtime(true) * 10000;
$strlen = strlen($hex_code);
原文链接:https://www.f2er.com/php/22306.html$hash_code = hash('sha256',$string);
// 这里会为编码定义一个<a href="https://www.jb51.cc/tag/suiji/" target="_blank" class="keywords">随机</a>的长度,长度取决于step
$step = rand(8,16);
$count = ceil(strlen($hash_code) / $step);
for($i = 0; $i < $count; $i++) {
$start = $i * $step;
$hex_num = substr($hash_code,$start,$step);
$num = 0x3fffffff & (1 * '0x' . $hex_num);
$n = $num % $strlen;
$code .= $hex_code[$n];
}
return $code;
}