Home >Backend Development >PHP Tutorial >来看代码了!该如何解决
来看代码了!
无聊的时候瞎写的,欢迎大虾们指正
<br>Common\NDV.php<br>/**<br> * NDV (Not complete Digital Visa)<br> * 非完整数字签证<br> *<br> * +----------------------------------------------------+<br> * * NDV(基础函数库文件),属于KSEF(Kee Simply Efficient Framework)项目扩展库函数<br> * @author Kee <br> * @date 2012年12月10日<br> * @version Alpha 1.0<br><br><br> * +----------------------------------------------------+<br> */<br>class NDV{<br> private $Str_list = array();<br> private $SafeStr = null;<br> private $BinCode = null;<br> private $Md5Code = null;<br> private $Sh1Code = null;<br> private $SafeCode = null;<br> <br> public function NDVa($str, $mode = 'NDV'){<br> $this-> NDV_list($str);<br> $this-> NDV_Safe_Add();<br> $this-> NDV_4in1();<br> if($mode == 'NDV'){<br> //输出52位混合编码,默认选项<br> return $this-> SafeCode;<br> }elseif($mode == 'BIN'){<br> //输出20位二进制校验码<br> return $this-> BinCode;<br> }elseif($mode == 'MD5'){<br> //输出32为MD5校验码<br> return $this-> Md5Code;<br> }elseif($mode == 'SH1'){<br> //输出32位Sh1校验码<br> return $this-> Sh1Code;<br> }<br> }<br><br> private function NDV_list($str) {<br> $Str_Len = strlen($str); //计算字符串长度<br> $Str_Arr = array(); //拆解字符串数组<br> $Str_list = array(); //混序列表<br>// $mod3 = $Str_Len%3; //模3值<br> $Len3 = intval($Str_Len / 3); //除3取整<br> $list = 0;<br> <br> //进行一次循环,拆解字符串,混序排列<br> for ($i = 0, $x = 0; $i $Str_Arr[$x] = md5(md5(substr($str, $i, 3)) . md5($str)); //拆解字符串,取字符串摘要获取64位混合编码<br> //混序排列<br> $this->BinCode .= $Str_Arr[$x] % 2;<br> if ($Str_Arr[$x] % 2 == 1) {<br> //如果模2值为1,则序列下沉<br> $Str_list[$Len3] = $Str_Arr[$x];<br> $Len3--;<br> } elseif ($Str_Arr[$x] % 2 == 0) {<br> //如果模2值为0,则序列上浮<br> $Str_list[$list] = $Str_Arr[$x];<br> $list++;<div class="clear"> </div>