Exemplo n.º 1
0
 /**
  *
  * @see \CryptoUtil\PBE\PBEScheme::decryptWithKey()
  * @throws \UnexpectedValueException If decryption failed
  * @return string
  */
 public function decryptWithKey($data, $key)
 {
     try {
         $str = $this->_crypto->decrypt($data, $key, $this->_cipher);
         return $this->_removePadding($str, $this->_cipher->blockSize());
     } catch (\RuntimeException $e) {
         throw new \UnexpectedValueException("Decryption failed.", null, $e);
     }
 }
Exemplo n.º 2
0
 /**
  *
  * @see \CryptoUtil\PBE\PBEScheme::decryptWithKey()
  * @throws \UnexpectedValueException If decryption failed
  * @return string
  */
 public function decryptWithKey($data, $key)
 {
     if (strlen($key) !== 16) {
         throw new \UnexpectedValueException("Invalid key length.");
     }
     try {
         $algo = $this->_cipher->withInitializationVector(substr($key, 8, 8));
         $str = $this->_crypto->decrypt($data, substr($key, 0, 8), $algo);
         return $this->_removePadding($str, 8);
     } catch (\RuntimeException $e) {
         throw new \UnexpectedValueException("Decryption failed.", null, $e);
     }
 }