Пример #1
0
/**
 * Encryption using blowfish algorithm
 *
 * @param   string  original data
 * @param   string  the secret
 *
 * @return  string  the encrypted result
 *
 * @access  public
 *
 * @author  lem9
 */
function PMA_blowfish_encrypt($data, $secret)
{
    $pma_cipher = new Horde_Cipher_blowfish();
    $encrypt = '';
    for ($i = 0; $i < strlen($data); $i += 8) {
        $block = substr($data, $i, 8);
        if (strlen($block) < 8) {
            $block = full_str_pad($block, 8, "", 1);
        }
        $encrypt .= $pma_cipher->encryptBlock($block, $secret);
    }
    return $encrypt;
}
Пример #2
0
/**
 * Encryption using blowfish algorithm
 *
 * @param   string  original data
 * @param   string  the secret
 *
 * @return  string  the encrypted result
 *
 * @access  public
 *
 * @author  lem9 (taken from the phpMyAdmin source)
 */
function pla_blowfish_encrypt($data, $secret = null)
{
    if (DEBUG_ENABLED) {
        debug_log('pla_blowfish_encrypt(): Entered with (%s,%s)', 1, $data, $secret);
    }
    global $config;
    # 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 $data;
    }
    require_once LIBDIR . 'blowfish.php';
    $pma_cipher = new Horde_Cipher_blowfish();
    $encrypt = '';
    for ($i = 0; $i < strlen($data); $i += 8) {
        $block = substr($data, $i, 8);
        if (strlen($block) < 8) {
            $block = full_str_pad($block, 8, "", 1);
        }
        $encrypt .= $pma_cipher->encryptBlock($block, $secret);
    }
    return base64_encode($encrypt);
}
Пример #3
0
/**
 * Encryption using blowfish algorithm
 *
 * @param string Original data
 * @param string The secret
 * @return string The encrypted result
 * @author lem9 (taken from the phpMyAdmin source)
 */
function blowfish_encrypt($data, $secret = null)
{
    if (DEBUG_ENABLED && (($fargs = func_get_args()) || ($fargs = 'NOARGS'))) {
        debug_log('Entered (%%)', 1, 0, __FILE__, __LINE__, __METHOD__, $fargs);
    }
    # 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 $data;
    }
    if (function_exists('mcrypt_module_open') && !empty($data)) {
        $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);
        $encrypted_data = base64_encode(mcrypt_generic($td, $data));
        mcrypt_generic_deinit($td);
        return $encrypted_data;
    }
    if (file_exists(LIBDIR . 'blowfish.php')) {
        require_once LIBDIR . 'blowfish.php';
    } else {
        return $data;
    }
    $pma_cipher = new Horde_Cipher_blowfish();
    $encrypt = '';
    for ($i = 0; $i < strlen($data); $i += 8) {
        $block = substr($data, $i, 8);
        if (strlen($block) < 8) {
            $block = full_str_pad($block, 8, "", 1);
        }
        $encrypt .= $pma_cipher->encryptBlock($block, $secret);
    }
    return base64_encode($encrypt);
}
Пример #4
0
/**
 * Encryption using blowfish algorithm
 *
 * @param string Original data
 * @param string The secret
 * @return string The encrypted result
 * @author lem9 (taken from the phpMyAdmin source)
 */
function blowfish_encrypt($data, $secret = null)
{
    if (DEBUG_ENABLED && (($fargs = func_get_args()) || ($fargs = 'NOARGS'))) {
        debug_log('Entered (%%)', 1, 0, __FILE__, __LINE__, __METHOD__, $fargs);
    }
    # 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 $data;
    }
    if (file_exists(LIBDIR . 'blowfish.php')) {
        require_once LIBDIR . 'blowfish.php';
    } else {
        return $data;
    }
    $pma_cipher = new Horde_Cipher_blowfish();
    $encrypt = '';
    for ($i = 0; $i < strlen($data); $i += 8) {
        $block = substr($data, $i, 8);
        if (strlen($block) < 8) {
            $block = full_str_pad($block, 8, "", 1);
        }
        $encrypt .= $pma_cipher->encryptBlock($block, $secret);
    }
    return base64_encode($encrypt);
}