來看代碼了!該如何解決

來源:互聯網
上載者:User
來看代碼了!
無聊的時候瞎寫的,歡迎大蝦們指正

Common\NDV.php
/**
* NDV (Not complete Digital Visa)
* 非完整數字簽證
*
* +----------------------------------------------------+
* * NDV(基礎函數庫檔案),屬於KSEF(Kee Simply Efficient Framework)項目擴充庫函數
* @author Kee <[email protected]>
* @date 2012年12月10日
* @version Alpha 1.0


* +----------------------------------------------------+
*/
class NDV{
private $Str_list = array();
private $SafeStr = null;
private $BinCode = null;
private $Md5Code = null;
private $Sh1Code = null;
private $SafeCode = null;

public function NDVa($str, $mode = 'NDV'){
$this-> NDV_list($str);
$this-> NDV_Safe_Add();
$this-> NDV_4in1();
if($mode == 'NDV'){
//輸出52位混合編碼,預設選項
return $this-> SafeCode;
}elseif($mode == 'BIN'){
//輸出20位二進位校正碼
return $this-> BinCode;
}elseif($mode == 'MD5'){
//輸出32為MD5校正碼
return $this-> Md5Code;
}elseif($mode == 'SH1'){
//輸出32位Sh1校正碼
return $this-> Sh1Code;
}
}

private function NDV_list($str) {
$Str_Len = strlen($str); //計算字串長度
$Str_Arr = array(); //拆解字串數組
$Str_list = array(); //混序列表
// $mod3 = $Str_Len%3; //模3值
$Len3 = intval($Str_Len / 3); //除3取整
$list = 0;

//進行一次迴圈,拆解字串,混序排列
for ($i = 0, $x = 0; $i < $Str_Len; $x++) {
$Str_Arr[$x] = md5(md5(substr($str, $i, 3)) . md5($str)); //拆解字串,取字串摘要擷取64位混合編碼
//混序排列
$this->BinCode .= $Str_Arr[$x] % 2;
if ($Str_Arr[$x] % 2 == 1) {
//如果模2值為1,則序列下沉
$Str_list[$Len3] = $Str_Arr[$x];
$Len3--;
} elseif ($Str_Arr[$x] % 2 == 0) {
//如果模2值為0,則序列上浮
$Str_list[$list] = $Str_Arr[$x];
$list++;
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.