当前位置: 首页>>代码示例>>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;未经允许,请勿转载。