示例#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');
     }
 }