예제 #1
0
 public function testDecryptPadding()
 {
     $des = new DES(Base::MODE_CBC);
     $des->disablePadding();
     // when the key and iv are not specified they should be null padded
     //$des->setKey();
     //$des->setIV();
     $des->setPreferredEngine(Base::ENGINE_INTERNAL);
     $internal = $des->decrypt('d');
     $result = pack('H*', '79b305d1ce555221');
     $this->assertEquals($result, $internal, 'Failed asserting that the internal engine produced the correct result');
     $des->setPreferredEngine(Base::ENGINE_MCRYPT);
     if ($des->getEngine() == Base::ENGINE_MCRYPT) {
         $mcrypt = $des->decrypt('d');
         $this->assertEquals($result, $mcrypt, 'Failed asserting that the mcrypt engine produced the correct result');
     } else {
         self::markTestSkipped('Unable to initialize mcrypt engine');
     }
     $des->setPreferredEngine(Base::ENGINE_OPENSSL);
     if ($des->getEngine() == Base::ENGINE_OPENSSL) {
         $openssl = $des->decrypt('d');
         $this->assertEquals($result, $openssl, 'Failed asserting that the OpenSSL engine produced the correct result');
     } else {
         self::markTestSkipped('Unable to initialize OpenSSL engine');
     }
 }
예제 #2
0
파일: TripleDES.php 프로젝트: bodun/jorani
 /**
  * Sets the internal crypt engine
  *
  * @see \phpseclib\Crypt\Base::Crypt_Base()
  * @see \phpseclib\Crypt\Base::setPreferredEngine()
  * @param Integer $engine
  * @access public
  * @return Integer
  */
 function setPreferredEngine($engine)
 {
     if ($this->mode_3cbc) {
         $this->des[0]->setPreferredEngine($engine);
         $this->des[1]->setPreferredEngine($engine);
         $this->des[2]->setPreferredEngine($engine);
     }
     return parent::setPreferredEngine($engine);
 }