當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Crypt_DES::enableContinuousBuffer方法代碼示例

本文整理匯總了PHP中Crypt_DES::enableContinuousBuffer方法的典型用法代碼示例。如果您正苦於以下問題:PHP Crypt_DES::enableContinuousBuffer方法的具體用法?PHP Crypt_DES::enableContinuousBuffer怎麽用?PHP Crypt_DES::enableContinuousBuffer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Crypt_DES的用法示例。


在下文中一共展示了Crypt_DES::enableContinuousBuffer方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: enableContinuousBuffer

 /**
  * Treat consecutive "packets" as if they are a continuous buffer.
  *
  * Say you have a 16-byte plaintext $plaintext.  Using the default behavior, the two following code snippets
  * will yield different outputs:
  *
  * <code>
  *    echo $des->encrypt(substr($plaintext, 0, 8));
  *    echo $des->encrypt(substr($plaintext, 8, 8));
  * </code>
  * <code>
  *    echo $des->encrypt($plaintext);
  * </code>
  *
  * The solution is to enable the continuous buffer.  Although this will resolve the above discrepancy, it creates
  * another, as demonstrated with the following:
  *
  * <code>
  *    $des->encrypt(substr($plaintext, 0, 8));
  *    echo $des->decrypt($des->encrypt(substr($plaintext, 8, 8)));
  * </code>
  * <code>
  *    echo $des->decrypt($des->encrypt(substr($plaintext, 8, 8)));
  * </code>
  *
  * With the continuous buffer disabled, these would yield the same output.  With it enabled, they yield different
  * outputs.  The reason is due to the fact that the initialization vector's change after every encryption /
  * decryption round when the continuous buffer is enabled.  When it's disabled, they remain constant.
  *
  * Put another way, when the continuous buffer is enabled, the state of the Crypt_DES() object changes after each
  * encryption / decryption round, whereas otherwise, it'd remain constant.  For this reason, it's recommended that
  * continuous buffers not be used.  They do offer better security and are, in fact, sometimes required (SSH uses them),
  * however, they are also less intuitive and more likely to cause you problems.
  *
  * @see Crypt_Base::enableContinuousBuffer()
  * @see Crypt_TripleDES::disableContinuousBuffer()
  * @access public
  */
 function enableContinuousBuffer()
 {
     parent::enableContinuousBuffer();
     if ($this->mode_3cbc) {
         $this->des[0]->enableContinuousBuffer();
         $this->des[1]->enableContinuousBuffer();
         $this->des[2]->enableContinuousBuffer();
     }
 }
開發者ID:anthrotech,項目名稱:laravel_sample,代碼行數:47,代碼來源:TripleDES.php


注:本文中的Crypt_DES::enableContinuousBuffer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。