网站首页 包含标签 易语言 的所有文章

  • 易语言/PHP/JS QQ BKN/GTK计算方法

    GTK跟BKN 据我了解是一种东西 易语言版 .版本 2 .子程序 计算bkn, 文本型 .参数 Skey, 文本型 .局部变量 基值, 整数型 .局部变量 计数, 整数型 .局部变量 长度, 整数型 .局部变量 结果, 整数型 基值 = 5381 计数 = 0 长度 = 取文本长度 (Skey) .判断循环首 (计数 < 长度) 基值 = 基值 + 左移 (基值, 5) + 取代码 (Skey, 计数 + 1) 计数 = 计数 + 1 .判断循环尾 () 结果 = 位与 (基值, 2147483647) 返回 (到文本 (结果)) JS版 function getBKN(str){ var hash = 5381; for(var i = 0, len = str.length; i < len; ++i) { hash += (hash << 5) + str.charAt(i).charCodeAt(); } return hash & 0x7fffffff; } PHP版 public function bkn($skey) {     $hash = 5381;     for ($i = 0, $len = strlen($skey); $i < $len; ++$i){         $hash +=($hash << 5) + charCodeAt($skey, $i);     }     return $hash & 2147483647; } public function charCodeAt($str, $index){     $char = mb_substr($str, $index, 1, 'UTF-8');     $value = null;     if (mb_check_encoding($char, 'UTF-8')){         $ret = mb_convert_encoding($char, 'UTF-32BE', 'UTF-8');         $value = hexdec(bin2hex($ret));     }     return $value; } ...

    2022-06-14 409

联系我们

在线咨询:点击这里给我发消息

QQ交流群:KirinBlog

工作日:8:00-23:00,节假日休息

扫码关注