当前位置: 首页>>代码示例>>PHP>>正文


PHP Crypt_Rijndael::decrypt方法代码示例

本文整理汇总了PHP中Crypt_Rijndael::decrypt方法的典型用法代码示例。如果您正苦于以下问题:PHP Crypt_Rijndael::decrypt方法的具体用法?PHP Crypt_Rijndael::decrypt怎么用?PHP Crypt_Rijndael::decrypt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Crypt_Rijndael的用法示例。


在下文中一共展示了Crypt_Rijndael::decrypt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Crypto

 public static function Crypto($text, $cipher, $key, $isEncrypt)
 {
     switch ($cipher) {
         case 'DES':
             $crypt = new Crypt_DES(CRYPT_DES_MODE_CBC);
             $crypt->setKey($key);
             $crypt->setIV($key);
             if ($isEncrypt) {
                 return strtoupper(bin2hex($crypt->encrypt($text)));
             } else {
                 return $crypt->decrypt(CryptoUtil::hex2bin($text));
             }
             break;
         case 'AES-256':
             $crypt = new Crypt_Rijndael(CRYPT_RIJNDAEL_MODE_ECB);
             $crypt->setKey($key);
             if ($isEncrypt) {
                 return strtoupper(bin2hex($crypt->encrypt($text)));
             } else {
                 return $crypt->decrypt(CryptoUtil::hex2bin($text));
             }
             break;
         default:
             break;
     }
     return "ERROR";
 }
开发者ID:jemmy655,项目名称:OpenCart-API-service-by-Kancart.com-Mobile,代码行数:27,代码来源:CryptoUtil.php

示例2: rijndael_decrypt_file

function rijndael_decrypt_file($file, $key)
{
    require_once dirname(__FILE__) . '/includes/phpseclib/Crypt/Rijndael.php';
    $rijndael = new Crypt_Rijndael();
    $rijndael->setKey($key);
    $ciphertext = file_get_contents($file);
    print $rijndael->decrypt($ciphertext);
}
开发者ID:taeche,项目名称:SoDoEx,代码行数:8,代码来源:example-decrypt.php

示例3: decrypt_message

function decrypt_message($message, $asym_key)
{
    $rsa = new Crypt_RSA();
    $rij = new Crypt_Rijndael();
    // Extract the Symmetric Key
    $len = substr($message, 0, 3);
    $len = hexdec($len);
    $sym_key = substr($message, 0, $len);
    //Extract the encrypted message
    $message = substr($message, 3);
    $ciphertext = substr($message, $len);
    $ciphertext = base64_decode($ciphertext);
    // Decrypt the encrypted symmetric key
    $rsa->loadKey($asym_key);
    $sym_key = base64_decode($sym_key);
    $sym_key = $rsa->decrypt($sym_key);
    // Decrypt the message
    $rij->setKey($sym_key);
    $plaintext = $rij->decrypt($ciphertext);
    return $message;
}
开发者ID:Zeeshan-Afzal92,项目名称:RSA-Cryptography,代码行数:21,代码来源:encrypt_decrypt.php

示例4: decrypt

 /**
  * Decrypts a message.
  *
  * If strlen($ciphertext) is not a multiple of 16, null bytes will be added to the end of the string until it is.
  *
  * @see Crypt_AES::encrypt()
  * @access public
  * @param String $ciphertext
  */
 function decrypt($ciphertext)
 {
     if (CRYPT_AES_MODE == CRYPT_AES_MODE_MCRYPT) {
         $this->_mcryptSetup();
         /*
         if ($this->mode == CRYPT_AES_MODE_CTR) {
             $iv = $this->decryptIV;
             $xor = mcrypt_generic($this->enmcrypt, $this->_generate_xor(strlen($ciphertext), $iv));
             $plaintext = $ciphertext ^ $xor;
             if ($this->continuousBuffer) {
                 $this->decryptIV = $iv;
             }
             return $plaintext;
         }
         */
         if ($this->mode != 'ctr') {
             // we pad with chr(0) since that's what mcrypt_generic does.  to quote from http://php.net/function.mcrypt-generic :
             // "The data is padded with "\0" to make sure the length of the data is n * blocksize."
             $ciphertext = str_pad($ciphertext, strlen($ciphertext) + 15 & 0xfffffff0, chr(0));
         }
         $plaintext = mdecrypt_generic($this->demcrypt, $ciphertext);
         if (!$this->continuousBuffer) {
             mcrypt_generic_init($this->demcrypt, $this->key, $this->iv);
         }
         return $this->mode != 'ctr' ? $this->_unpad($plaintext) : $plaintext;
     }
     return parent::decrypt($ciphertext);
 }
开发者ID:ccq18,项目名称:EduSoho,代码行数:37,代码来源:AES.php

示例5: decrypt_message

 public function decrypt_message($message)
 {
     if (!$this->key_local) {
         throw new Exception('No decryption key has been set');
     }
     $this->ensure_crypto_loaded();
     $rsa = new Crypt_RSA();
     $rij = new Crypt_Rijndael();
     // Extract the Symmetric Key
     $len = substr($message, 0, 3);
     $len = hexdec($len);
     $sym_key = substr($message, 3, $len);
     // Extract the encrypted message
     $cipherlen = substr($message, $len + 3, 16);
     $cipherlen = hexdec($cipherlen);
     $ciphertext = substr($message, $len + 19, $cipherlen);
     $ciphertext = base64_decode($ciphertext);
     // Decrypt the encrypted symmetric key
     $rsa->loadKey($this->key_local);
     $sym_key = base64_decode($sym_key);
     $sym_key = $rsa->decrypt($sym_key);
     // Decrypt the message
     $rij->setKey($sym_key);
     return $rij->decrypt($ciphertext);
 }
开发者ID:beyond-z,项目名称:braven,代码行数:25,代码来源:class-udrpc.php

示例6: decrypt

 /**
  * Decrypts a message.
  *
  * If strlen($ciphertext) is not a multiple of 16, null bytes will be added to the end of the string until it is.
  *
  * @see Crypt_AES::encrypt()
  * @access public
  * @param String $ciphertext
  */
 function decrypt($ciphertext)
 {
     if (CRYPT_AES_MODE == CRYPT_AES_MODE_MCRYPT) {
         $changed = $this->changed;
         $this->_mcryptSetup();
         /*
         if ($this->mode == CRYPT_AES_MODE_CTR) {
             $iv = $this->decryptIV;
             $xor = mcrypt_generic($this->enmcrypt, $this->_generate_xor(strlen($ciphertext), $iv));
             $plaintext = $ciphertext ^ $xor;
             if ($this->continuousBuffer) {
                 $this->decryptIV = $iv;
             }
             return $plaintext;
         }
         */
         if ($this->mode == 'ncfb') {
             if ($changed) {
                 $this->ecb = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_ECB, '');
                 mcrypt_generic_init($this->ecb, $this->key, "");
             }
             if (strlen($this->debuffer)) {
                 $plaintext = $ciphertext ^ substr($this->decryptIV, strlen($this->debuffer));
                 $this->debuffer .= substr($ciphertext, 0, strlen($plaintext));
                 if (strlen($this->debuffer) == 16) {
                     $this->decryptIV = $this->debuffer;
                     $this->debuffer = '';
                     mcrypt_generic_init($this->demcrypt, $this->key, $this->decryptIV);
                 }
                 $ciphertext = substr($ciphertext, strlen($plaintext));
             } else {
                 $plaintext = '';
             }
             $last_pos = strlen($ciphertext) & 0xfffffff0;
             $plaintext .= $last_pos ? mdecrypt_generic($this->demcrypt, substr($ciphertext, 0, $last_pos)) : '';
             if (strlen($ciphertext) & 0xf) {
                 if (strlen($plaintext)) {
                     $this->decryptIV = substr($ciphertext, $last_pos - 16, 16);
                 }
                 $this->decryptIV = mcrypt_generic($this->ecb, $this->decryptIV);
                 $this->debuffer = substr($ciphertext, $last_pos);
                 $plaintext .= $this->debuffer ^ $this->decryptIV;
             }
             return $plaintext;
         }
         if ($this->paddable) {
             // we pad with chr(0) since that's what mcrypt_generic does.  to quote from http://php.net/function.mcrypt-generic :
             // "The data is padded with "\0" to make sure the length of the data is n * blocksize."
             $ciphertext = str_pad($ciphertext, strlen($ciphertext) + 15 & 0xfffffff0, chr(0));
         }
         $plaintext = mdecrypt_generic($this->demcrypt, $ciphertext);
         if (!$this->continuousBuffer) {
             mcrypt_generic_init($this->demcrypt, $this->key, $this->iv);
         }
         return $this->paddable ? $this->_unpad($plaintext) : $plaintext;
     }
     return parent::decrypt($ciphertext);
 }
开发者ID:bbspike,项目名称:sentora-core,代码行数:67,代码来源:AES.php

示例7: decrypt_message

 public function decrypt_message($message)
 {
     if (!$this->key_local) {
         throw new Exception('No decryption key has been set');
     }
     $this->ensure_crypto_loaded();
     $rsa = new Crypt_RSA();
     if (defined('UDRPC_PHPSECLIB_ENCRYPTION_MODE')) {
         $rsa->setEncryptionMode(UDRPC_PHPSECLIB_ENCRYPTION_MODE);
     }
     // Defaults to CRYPT_AES_MODE_CBC
     $rij = new Crypt_Rijndael();
     // Extract the Symmetric Key
     $len = substr($message, 0, 3);
     $len = hexdec($len);
     $sym_key = substr($message, 3, $len);
     // Extract the encrypted message
     $cipherlen = substr($message, $len + 3, 16);
     $cipherlen = hexdec($cipherlen);
     $ciphertext = substr($message, $len + 19, $cipherlen);
     $ciphertext = base64_decode($ciphertext);
     // Decrypt the encrypted symmetric key
     $rsa->loadKey($this->key_local);
     $sym_key = base64_decode($sym_key);
     $sym_key = $rsa->decrypt($sym_key);
     // Decrypt the message
     $rij->setKey($sym_key);
     return $rij->decrypt($ciphertext);
 }
开发者ID:aaronfrey,项目名称:PepperLillie-Cambridge,代码行数:29,代码来源:class-udrpc.php

示例8: decrypt

 /**
  * Decrypts a message.
  *
  * If strlen($ciphertext) is not a multiple of 16, null bytes will be added to the end of the string until it is.
  *
  * @see Crypt_AES::encrypt()
  * @access public
  * @param String $ciphertext
  */
 function decrypt($ciphertext)
 {
     if (CRYPT_AES_MODE == CRYPT_AES_MODE_MCRYPT) {
         $this->_mcryptSetup();
         if ($this->mode == 'ncfb' && $this->continuousBuffer) {
             $iv =& $this->decryptIV;
             $pos =& $this->debuffer['pos'];
             $len = strlen($ciphertext);
             $plaintext = '';
             $i = 0;
             if ($pos) {
                 $orig_pos = $pos;
                 $max = 16 - $pos;
                 if ($len >= $max) {
                     $i = $max;
                     $len -= $max;
                     $pos = 0;
                 } else {
                     $i = $len;
                     $pos += $len;
                     $len = 0;
                 }
                 // ie. $i = min($max, $len), $len-= $i, $pos+= $i, $pos%= $blocksize
                 $plaintext = substr($iv, $orig_pos) ^ $ciphertext;
                 $iv = substr_replace($iv, substr($ciphertext, 0, $i), $orig_pos, $i);
             }
             if ($len >= 16) {
                 $cb = substr($ciphertext, $i, $len - $len % 16);
                 $plaintext .= mcrypt_generic($this->ecb, $iv . $cb) ^ $cb;
                 $iv = substr($cb, -16);
                 $len %= 16;
             }
             if ($len) {
                 $iv = mcrypt_generic($this->ecb, $iv);
                 $plaintext .= $iv ^ substr($ciphertext, -$len);
                 $iv = substr_replace($iv, substr($ciphertext, -$len), 0, $len);
                 $pos = $len;
             }
             return $plaintext;
         }
         if ($this->paddable) {
             // we pad with chr(0) since that's what mcrypt_generic does.  to quote from http://php.net/function.mcrypt-generic :
             // "The data is padded with "\0" to make sure the length of the data is n * blocksize."
             $ciphertext = str_pad($ciphertext, strlen($ciphertext) + 15 & 0xfffffff0, chr(0));
         }
         $plaintext = mdecrypt_generic($this->demcrypt, $ciphertext);
         if (!$this->continuousBuffer) {
             mcrypt_generic_init($this->demcrypt, $this->key, $this->iv);
         }
         return $this->paddable ? $this->_unpad($plaintext) : $plaintext;
     }
     return parent::decrypt($ciphertext);
 }
开发者ID:pradhmanyu,项目名称:ost,代码行数:62,代码来源:AES.php

示例9: decrypt

 public function decrypt($ciphertext)
 {
     if (CRYPT_AES_MODE == CRYPT_AES_MODE_MCRYPT) {
         $this->_mcryptSetup();
         if ($this->mode == 'ncfb' && $this->continuousBuffer) {
             $iv =& $this->decryptIV;
             $pos =& $this->debuffer['pos'];
             $len = strlen($ciphertext);
             $plaintext = '';
             $i = 0;
             if ($pos) {
                 $orig_pos = $pos;
                 $max = 16 - $pos;
                 if ($max <= $len) {
                     $i = $max;
                     $len -= $max;
                     $pos = 0;
                 } else {
                     $i = $len;
                     $pos += $len;
                     $len = 0;
                 }
                 $plaintext = substr($iv, $orig_pos) ^ $ciphertext;
                 $iv = substr_replace($iv, substr($ciphertext, 0, $i), $orig_pos, $i);
             }
             if (16 <= $len) {
                 $cb = substr($ciphertext, $i, $len - $len % 16);
                 $plaintext .= mcrypt_generic($this->ecb, $iv . $cb) ^ $cb;
                 $iv = substr($cb, -16);
                 $len %= 16;
             }
             if ($len) {
                 $iv = mcrypt_generic($this->ecb, $iv);
                 $plaintext .= $iv ^ substr($ciphertext, 0 - $len);
                 $iv = substr_replace($iv, substr($ciphertext, 0 - $len), 0, $len);
                 $pos = $len;
             }
             return $plaintext;
         }
         if ($this->paddable) {
             $ciphertext = str_pad($ciphertext, strlen($ciphertext) + 15 & 4294967280, chr(0));
         }
         $plaintext = mdecrypt_generic($this->demcrypt, $ciphertext);
         if (!$this->continuousBuffer) {
             mcrypt_generic_init($this->demcrypt, $this->key, $this->iv);
         }
         return $this->paddable ? $this->_unpad($plaintext) : $plaintext;
     }
     return parent::decrypt($ciphertext);
 }
开发者ID:fkssei,项目名称:pigcms10,代码行数:50,代码来源:Crypt_AES.php

示例10: foreach

 function unpack_package($package, $delete_package = true)
 {
     global $wp_filesystem, $updraftplus;
     $updraft_dir = $updraftplus->backups_dir_location();
     // If not database, then it is a zip - unpack in the usual way
     if (!preg_match('/db\\.gz(\\.crypt)?$/i', $package)) {
         return parent::unpack_package($updraft_dir . '/' . $package, $delete_package);
     }
     $backup_dir = $wp_filesystem->find_folder($updraft_dir);
     // Unpack a database. The general shape of the following is copied from class-wp-upgrader.php
     @set_time_limit(1800);
     $this->skin->feedback('unpack_package');
     $upgrade_folder = $wp_filesystem->wp_content_dir() . 'upgrade/';
     @$wp_filesystem->mkdir($upgrade_folder, 0775);
     //Clean up contents of upgrade directory beforehand.
     $upgrade_files = $wp_filesystem->dirlist($upgrade_folder);
     if (!empty($upgrade_files)) {
         foreach ($upgrade_files as $file) {
             $wp_filesystem->delete($upgrade_folder . $file['name'], true);
         }
     }
     //We need a working directory
     $working_dir = $upgrade_folder . basename($package, '.crypt');
     # $working_dir_filesystem = WP_CONTENT_DIR.'/upgrade/'. basename($package, '.crypt');
     // Clean up working directory
     if ($wp_filesystem->is_dir($working_dir)) {
         $wp_filesystem->delete($working_dir, true);
     }
     if (!$wp_filesystem->mkdir($working_dir, 0775)) {
         return new WP_Error('mkdir_failed', __('Failed to create a temporary directory', 'updraftplus') . ' (' . $working_dir . ')');
     }
     // Unpack package to working directory
     if ($updraftplus->is_db_encrypted($package)) {
         $this->skin->feedback('decrypt_database');
         $encryption = UpdraftPlus_Options::get_updraft_option('updraft_encryptionphrase');
         if (!$encryption) {
             return new WP_Error('no_encryption_key', __('Decryption failed. The database file is encrypted, but you have no encryption key entered.', 'updraftplus'));
         }
         // Encrypted - decrypt it
         require_once UPDRAFTPLUS_DIR . '/includes/phpseclib/Crypt/Rijndael.php';
         $rijndael = new Crypt_Rijndael();
         // Get decryption key
         $rijndael->setKey($encryption);
         $ciphertext = $rijndael->decrypt($wp_filesystem->get_contents($backup_dir . $package));
         if ($ciphertext) {
             $this->skin->feedback('decrypted_database');
             if (!$wp_filesystem->put_contents($working_dir . '/backup.db.gz', $ciphertext)) {
                 return new WP_Error('write_failed', __('Failed to write out the decrypted database to the filesystem', 'updraftplus'));
             }
         } else {
             return new WP_Error('decryption_failed', __('Decryption failed. The most likely cause is that you used the wrong key.', 'updraftplus'));
         }
     } else {
         if (!$wp_filesystem->copy($backup_dir . $package, $working_dir . '/backup.db.gz')) {
             if ($wp_filesystem->errors->get_error_code()) {
                 foreach ($wp_filesystem->errors->get_error_messages() as $message) {
                     show_message($message);
                 }
             }
             return new WP_Error('copy_failed', $this->strings['copy_failed']);
         }
     }
     // Once extracted, delete the package if required (non-recursive, is a file)
     if ($delete_package) {
         $wp_filesystem->delete($backup_dir . $package, false, true);
     }
     return $working_dir;
 }
开发者ID:brandmobility,项目名称:kikbak,代码行数:68,代码来源:restorer.php

示例11: hash

 function osc_decrypt_alert($string) {
     $key = hash("sha256", osc_get_alert_private_key(), true);
     if(function_exists('mcrypt_module_open')) {
         $cipher = mcrypt_module_open(MCRYPT_RIJNDAEL_256, '', MCRYPT_MODE_CBC, '');
         $cipherText = '';
         if (mcrypt_generic_init($cipher, $key, $key) != -1) {
             $cipherText = mdecrypt_generic($cipher, $string);
             mcrypt_generic_deinit($cipher);
         }
         return trim(substr($cipherText, 32));
     };
     require_once LIB_PATH . 'phpseclib/Crypt/Rijndael.php';
     $cipher = new Crypt_Rijndael(CRYPT_RIJNDAEL_MODE_CBC);
     $cipher->disablePadding();
     $cipher->setBlockLength(256);
     $cipher->setKey($key);
     $cipher->setIV($key);
     return trim(substr($cipher->decrypt($string), 32));
 }
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:19,代码来源:hSecurity.php

示例12: basename

 function spool_file($type, $fullpath, $encryption = "")
 {
     @set_time_limit(900);
     if (file_exists($fullpath)) {
         $file = basename($fullpath);
         $len = filesize($fullpath);
         $filearr = explode('.', $file);
         // 			//we've only got zip and gz...for now
         $file_ext = array_pop($filearr);
         header("Cache-Control: no-cache, must-revalidate");
         // HTTP/1.1
         header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
         // Date in the past
         header("Content-Length: {$len};");
         if ($file_ext == 'crypt') {
             if ($encryption == "") {
                 $encryption = UpdraftPlus_Options::get_updraft_option('updraft_encryptionphrase');
             }
             if ($encryption == "") {
                 header('Content-type: text/plain');
                 _e("Decryption failed. The database file is encrypted, but you have no encryption key entered.", 'updraftplus');
                 $this->log('Decryption of database failed: the database file is encrypted, but you have no encryption key entered.', 'error');
             } else {
                 if (!class_exists('Crypt_Rijndael')) {
                     require_once UPDRAFTPLUS_DIR . '/includes/phpseclib/Crypt/Rijndael.php';
                 }
                 $rijndael = new Crypt_Rijndael();
                 $rijndael->setKey($encryption);
                 $ciphertext = $rijndael->decrypt(file_get_contents($fullpath));
                 if ($ciphertext) {
                     header('Content-type: application/octet-stream');
                     header("Content-Disposition: attachment; filename=\"" . substr($file, 0, -6) . "\";");
                     print $ciphertext;
                 } else {
                     header('Content-type: text/plain');
                     echo __("Decryption failed. The most likely cause is that you used the wrong key.", 'updraftplus') . " " . __('The decryption key used:', 'updraftplus') . ' ' . $encryption;
                 }
             }
         } else {
             if ($file_ext == 'zip') {
                 header('Content-type: application/zip');
             } else {
                 header('Content-type: application/octet-stream');
             }
             header("Content-Disposition: attachment; filename=\"{$file}\";");
             # Prevent the file being read into memory
             @ob_end_flush();
             readfile($fullpath);
         }
         // 			$this->delete_local($file);
     } else {
         echo __('File not found', 'updraftplus');
     }
 }
开发者ID:brandmobility,项目名称:kikbak,代码行数:54,代码来源:updraftplus.php

示例13: decrypt

 /**
  *
  * Decrypts given value with given key (hex decoding it first)
  *
  * Compatible with mysql: "aes_decrypt(unhex($val), $key)
  *
  * @param string $val - value to encrypt
  * @param string $key - key
  * @return string decrypted value
  */
 public function decrypt($crypt, $key)
 {
     if (empty($crypt)) {
         return $crypt;
     }
     $crypt = pack("H*", $crypt);
     $mysqlKey = "";
     for ($a = 0; $a < strlen($key); $a++) {
         $mysqlKey[$a % 16] = chr(ord($mysqlKey[$a % 16]) ^ ord($key[$a]));
     }
     $aes = new Crypt_Rijndael(CRYPT_RIJNDAEL_MODE_ECB);
     $aes->setKeyLength(128);
     $aes->setBlockLength(128);
     $aes->setKey($mysqlKey);
     $decrypt = $aes->decrypt($crypt);
     return $decrypt;
 }
开发者ID:lahirwisada,项目名称:orangehrm,代码行数:27,代码来源:EncryptionListener.php

示例14: decrypt

 /**
  * Decrypt the ciphertext
  * @param string $cipherText
  * @return object \stdClass Unserialized token
  */
 public function decrypt($cipherText)
 {
     // Decryption: prefer mcrypt, if available (since it can decrypt data encrypted by either mcrypt or phpseclib)
     $cipherText = base64_decode($cipherText);
     $iv = substr($cipherText, 0, self::IV_SIZE);
     $cipherText = substr($cipherText, self::IV_SIZE);
     if (function_exists('mcrypt_decrypt')) {
         $token = @mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $this->key, $cipherText, MCRYPT_MODE_CBC, $iv);
     } else {
         global $updraftplus;
         $updraftplus->ensure_phpseclib('Crypt_Rijndael', 'Crypt/Rijndael');
         $rijndael = new Crypt_Rijndael();
         $rijndael->setKey($this->key);
         $rijndael->setIV($iv);
         $token = $rijndael->decrypt($cipherText);
     }
     return $token;
 }
开发者ID:jesusmarket,项目名称:jesusmarket,代码行数:23,代码来源:Encrypter.php

示例15: sprintf

 function analyse_db_file($timestamp, $res)
 {
     global $updraftplus;
     $backup = $updraftplus->get_backup_history($timestamp);
     if (!isset($backup['nonce']) || !isset($backup['db'])) {
         return;
     }
     $updraft_dir = $updraftplus->backups_dir_location();
     $db_file = $updraft_dir . '/' . $backup['db'];
     if (!is_readable($db_file)) {
         return;
     }
     // Encrypted - decrypt it
     if ($updraftplus->is_db_encrypted($db_file)) {
         $encryption = UpdraftPlus_Options::get_updraft_option('updraft_encryptionphrase');
         if (!$encryption) {
             echo sprintf(__('Error: %s', 'updraftplus'), __('Decryption failed. The database file is encrypted, but you have no encryption key entered.', 'updraftplus'));
             return;
         }
         require_once UPDRAFTPLUS_DIR . '/includes/phpseclib/Crypt/Rijndael.php';
         $rijndael = new Crypt_Rijndael();
         // Get decryption key
         $rijndael->setKey($encryption);
         $ciphertext = $rijndael->decrypt(file_get_contents($db_file));
         if ($ciphertext) {
             $new_db_file = $updraft_dir . '/' . basename($db_file, '.crypt');
             if (!file_put_contents($new_db_file, $ciphertext)) {
                 echo sprintf(__('Error: %s', 'updraftplus'), __('Failed to write out the decrypted database to the filesystem.', 'updraftplus'));
                 return false;
             }
             $db_file = $new_db_file;
         } else {
             echo sprintf(__('Error: %s', 'updraftplus'), __('Decryption failed. The most likely cause is that you used the wrong key.', 'updraftplus'));
             return false;
         }
     }
     $dbhandle = gzopen($db_file, 'r');
     if (!$dbhandle) {
         echo sprintf(__('Error: %s', 'updraftplus'), __('Failed to open database file.', 'updraftplus'));
         return false;
     }
     # Analyse the file, print the results.
     $line = 0;
     $old_siteurl = '';
     $old_table_prefix = '';
     $old_siteinfo = array();
     $gathering_siteinfo = true;
     while (!gzeof($dbhandle) && $line < 100) {
         $line++;
         // Up to 1Mb
         $buffer = rtrim(gzgets($dbhandle, 1048576));
         // Comments are what we are interested in
         if (substr($buffer, 0, 1) == '#') {
             // TODO: More information - e.g. WordPress version. Warn if importing new into old.
             if ('' == $old_siteurl && preg_match('/^\\# Backup of: (http(.*))$/', $buffer, $matches)) {
                 $old_siteurl = $matches[1];
                 echo __('Backup of:', 'updraftplus') . ' ' . htmlspecialchars($old_siteurl) . '<br>';
                 // Check for should-be migration
                 if ($old_siteurl != site_url()) {
                     echo apply_filters('updraftplus_dbscan_urlchange', sprintf(__('Error: %s', 'updraftplus'), '<a href="http://updraftplus.com/shop/migrator/">' . __('This backup set is from a different site - this is not a restoration, but a migration. You need the Migrator add-on in order to make this work.', 'updraftplus') . '</a>'), $old_siteurl, $res);
                 }
             } elseif ('' == $old_table_prefix && preg_match('/^\\# Table prefix: (\\S+)$/', $buffer, $matches)) {
                 $old_table_prefix = $matches[1];
                 // 					echo '<strong>'.__('Old table prefix:', 'updraftplus').'</strong> '.htmlspecialchars($old_table_prefix).'<br>';
             } elseif ($gathering_siteinfo && preg_match('/^\\# Site info: (\\S+)$/', $buffer, $matches)) {
                 if ('end' == $matches[1]) {
                     $gathering_siteinfo = false;
                     // Sanity checks
                     if (isset($old_siteinfo['multisite']) && !$old_siteinfo['multisite'] && is_multisite()) {
                         // Just need to check that you're crazy
                         if (!defined('UPDRAFTPLUS_EXPERIMENTAL_IMPORTINTOMULTISITE') || UPDRAFTPLUS_EXPERIMENTAL_IMPORTINTOMULTISITE != true) {
                             echo sprintf(__('Error: %s', 'updraftplus'), __('You are running on WordPress multisite - but your backup is not of a multisite site.', 'updraftplus'));
                             return false;
                         }
                         // Got the needed code?
                         if (!class_exists('UpdraftPlusAddOn_MultiSite') || !class_exists('UpdraftPlus_Addons_Migrator')) {
                             echo sprintf(__('Error: %s', 'updraftplus'), __('To import an ordinary WordPress site into a multisite installation requires both the multisite and migrator add-ons.', 'updraftplus'));
                             return false;
                         }
                     }
                 } elseif (preg_match('/^([^=]+)=(.*)$/', $matches[1], $kvmatches)) {
                     $key = $kvmatches[1];
                     $val = $kvmatches[2];
                     if ('multisite' == $key && $val) {
                         echo '<strong>' . __('Site information:', 'updraftplus') . '</strong>' . ' is a WordPress Network<br>';
                     }
                     $old_siteinfo[$key] = $val;
                 }
             }
         }
     }
     @gzclose($dbhandle);
 }
开发者ID:brandmobility,项目名称:kikbak,代码行数:93,代码来源:admin.php


注:本文中的Crypt_Rijndael::decrypt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。