php生成短域名函数

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了php生成短域名函数脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

PHP生成短域名函数

<PRe class="brush:PHP;"> public function createRandCode($string) { $code = ''; $hex_code = '1qaz2wsx3edc4rfv5t-gb6yhn7ujm8ik9ol0p_'; $Now = microtime(true) * 10000; $strlen = strlen($hex_code);
$hash_code = hash('sha256',$string);

// 这里会为编码定义<a href="https://www.js-code.COM/tag/yige/" target="_blank" class="keywords">一个</a><a href="https://www.js-code.com/tag/suiji/" target="_blank" class="keywords">随机</a>的长度,长度取决于step
$step = rand(8,16);
$count = ceil(strlen($hash_code) / $step);

for($i = 0; $i < $count; $i++) {
  <a href="https://www.js-code.com/tag/start/" target="_blank" class="keywords">$start</a> = $i * $step;
  $hex_num = substr($hash_code,<a href="https://www.js-code.com/tag/start/" target="_blank" class="keywords">$start</a>,$step);
  $num = 0x3fffffff &amp; (1 * '0x' . $hex_num);
  $n = $num % $strlen;
  $code .= $hex_code[$n];
}

return $code;

}

脚本宝典总结

以上是脚本宝典为你收集整理的php生成短域名函数全部内容,希望文章能够帮你解决php生成短域名函数所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签:php短域名