/** * Decryption using blowfish algorithm * * @param string $encdata encrypted data * @param string $secret the secret * * @return string original data */ public static function blowfishDecrypt($encdata, $secret) { $pma_cipher = new Horde_Cipher_blowfish(); $decrypt = ''; $data = base64_decode($encdata); foreach (str_split($data, 8) as $chunk) { $decrypt .= $pma_cipher->decryptBlock($chunk, $secret); } return trim($decrypt); }
/** * Decryption using blowfish algorithm * * @param string encrypted data * @param string the secret * * @return string original data * * @access public * * @author lem9 */ function PMA_blowfish_decrypt($encdata, $secret) { $pma_cipher = new Horde_Cipher_blowfish(); $decrypt = ''; $data = base64_decode($encdata); for ($i = 0; $i < strlen($data); $i += 8) { $decrypt .= $pma_cipher->decryptBlock(substr($data, $i, 8), $secret); } return trim($decrypt); }
/** * Decryption using blowfish algorithm * * @param string encrypted data * @param string the secret * * @return string original data * * @access public * * @author lem9 */ function PMA_blowfish_decrypt($encdata, $secret) { $pma_cipher = new Horde_Cipher_blowfish(); $decrypt = ''; $data = base64_decode($encdata); foreach (str_split($data, 8) as $chunk) { $decrypt .= $pma_cipher->decryptBlock($chunk, $secret); } return substr(rtrim($decrypt, ""), 0, -1); // triming fixed for DokuWiki FS#1690 FS#1713 }
/** * Decryption using blowfish algorithm * * @param string encrypted data * @param string the secret * * @return string original data * * @access public * * @author lem9 (taken from the phpMyAdmin source) */ function pla_blowfish_decrypt($encdata, $secret = null) { if (DEBUG_ENABLED) { debug_log('pla_blowfish_decrypt(): Entered with (%s,%s)', 1, $encdata, $secret); } global $config; // This cache gives major speed up for stupid callers :) static $cache = array(); if (isset($cache[$encdata])) { return $cache[$encdata]; } # If our secret is null or blank, get the default. if ($secret === null || !trim($secret)) { $secret = $config->GetValue('session', 'blowfish'); } # If the secret isnt set, then just return the data. if (!trim($secret)) { return $encdata; } require_once LIBDIR . 'blowfish.php'; $pma_cipher = new Horde_Cipher_blowfish(); $decrypt = ''; $data = base64_decode($encdata); for ($i = 0; $i < strlen($data); $i += 8) { $decrypt .= $pma_cipher->decryptBlock(substr($data, $i, 8), $secret); } $return = trim($decrypt); $cache[$encdata] = $return; return $return; }
/** * Decryption using blowfish algorithm * * @param string Encrypted data * @param string The secret * @return string Original data * @author lem9 (taken from the phpMyAdmin source) */ function blowfish_decrypt($encdata, $secret = null) { if (DEBUG_ENABLED && (($fargs = func_get_args()) || ($fargs = 'NOARGS'))) { debug_log('Entered (%%)', 1, 0, __FILE__, __LINE__, __METHOD__, $fargs); } # This cache gives major speed up for stupid callers :) static $CACHE = array(); if (isset($CACHE[$encdata])) { return $CACHE[$encdata]; } # If our secret is null or blank, get the default. if ($secret === null || !trim($secret)) { $secret = $_SESSION[APPCONFIG]->getValue('session', 'blowfish') ? $_SESSION[APPCONFIG]->getValue('session', 'blowfish') : session_id(); } # If the secret isnt set, then just return the data. if (!trim($secret)) { return $encdata; } if (function_exists('mcrypt_module_open') && !empty($encdata)) { $td = mcrypt_module_open(MCRYPT_BLOWFISH, '', MCRYPT_MODE_ECB, ''); $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_DEV_URANDOM); mcrypt_generic_init($td, substr($secret, 0, mcrypt_enc_get_key_size($td)), $iv); $decrypted_data = trim(mdecrypt_generic($td, base64_decode($encdata))); mcrypt_generic_deinit($td); return $decrypted_data; } if (file_exists(LIBDIR . 'blowfish.php')) { require_once LIBDIR . 'blowfish.php'; } else { return $encdata; } $pma_cipher = new Horde_Cipher_blowfish(); $decrypt = ''; $data = base64_decode($encdata); for ($i = 0; $i < strlen($data); $i += 8) { $decrypt .= $pma_cipher->decryptBlock(substr($data, $i, 8), $secret); } // Strip off our \0's that were added. $return = preg_replace("/\\0*\$/", '', $decrypt); $CACHE[$encdata] = $return; return $return; }
/** * Decryption using blowfish algorithm * * @param string Encrypted data * @param string The secret * @return string Original data * @author lem9 (taken from the phpMyAdmin source) */ function blowfish_decrypt($encdata, $secret = null) { if (DEBUG_ENABLED && (($fargs = func_get_args()) || ($fargs = 'NOARGS'))) { debug_log('Entered (%%)', 1, 0, __FILE__, __LINE__, __METHOD__, $fargs); } # This cache gives major speed up for stupid callers :) static $CACHE = array(); if (isset($CACHE[$encdata])) { return $CACHE[$encdata]; } # If our secret is null or blank, get the default. if ($secret === null || !trim($secret)) { $secret = $_SESSION[APPCONFIG]->getValue('session', 'blowfish') ? $_SESSION[APPCONFIG]->getValue('session', 'blowfish') : session_id(); } # If the secret isnt set, then just return the data. if (!trim($secret)) { return $encdata; } if (file_exists(LIBDIR . 'blowfish.php')) { require_once LIBDIR . 'blowfish.php'; } else { return $encdata; } $pma_cipher = new Horde_Cipher_blowfish(); $decrypt = ''; $data = base64_decode($encdata); for ($i = 0; $i < strlen($data); $i += 8) { $decrypt .= $pma_cipher->decryptBlock(substr($data, $i, 8), $secret); } $return = trim($decrypt); $CACHE[$encdata] = $return; return $return; }