2015-06-08 172 views
-2

請幫助。我如何製作一個加密和解密數組?DES加密和解密在PHP

<?php 
    class DES{ 

     function encrypt($plainText, $cipherKey){ 
      //plainText 
      $result = $this->toBiner($plainText); 
      $result = $this->InitialPermutation($result); 
      //key 
      $key = $this->toBiner($cipherKey); 
      $key = $this->kompresBit($key); 
      $arrLeftShift = $this->LeftShift($key); 
      //final 
      $result = $this->keyExpansion($result, $arrLeftShift); 
      return $result; 
     } 

     function decrypt($encryptedText, $cipherKey){ 
      $key = $this->toBiner($cipherKey); 
      $key = $this->kompresBit($key); 
      $arrLeftShift = $this->LeftShift($key); 

      $result = $this->reverseKeyExpansion($encryptedText, $arrLeftShift); 
      $result = $this->revInitialPermutation($result); 
+0

您的代碼有什麼問題?這是否工作?它不起作用嗎?你有沒有看到任何錯誤?你有什麼需要幫助的? –

回答