00001 <?php
00002
00003
00004
00005
00010
00011
00012
00013
00014 if (!isset($_COOKIE['pma_mcrypt_iv'])) {
00015 srand((double) microtime() * 1000000);
00016 $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_CBC), MCRYPT_RAND);
00017 setcookie('pma_mcrypt_iv',
00018 base64_encode($iv),
00019 time() + (60 * 60 * 24 * 30),
00020 $GLOBALS['cookie_path'], '',
00021 $GLOBALS['is_https']);
00022 } else {
00023 $iv = base64_decode($_COOKIE['pma_mcrypt_iv']);
00024 }
00025
00038 function full_str_pad($input, $pad_length, $pad_string = '', $pad_type = 0) {
00039 $str = '';
00040 $length = $pad_length - strlen($input);
00041 if ($length > 0) {
00042 if ($pad_type == STR_PAD_RIGHT) {
00043 $str = $input.str_repeat($pad_string, $length);
00044 } elseif ($pad_type == STR_PAD_BOTH) {
00045 $str = str_repeat($pad_string, floor($length/2));
00046 $str .= $input;
00047 $str .= str_repeat($pad_string, ceil($length/2));
00048 } else {
00049 $str = str_repeat($pad_string, $length).$input;
00050 }
00051 } else {
00052 $str = $input;
00053 }
00054 return $str;
00055 }
00068 function PMA_blowfish_encrypt($data, $secret) {
00069 global $iv;
00070
00071
00072
00073 return base64_encode(mcrypt_encrypt(MCRYPT_BLOWFISH, $secret, $data, MCRYPT_MODE_CBC, $iv));
00074 }
00075
00088 function PMA_blowfish_decrypt($encdata, $secret) {
00089 global $iv;
00090 return trim(mcrypt_decrypt(MCRYPT_BLOWFISH, $secret, base64_decode($encdata), MCRYPT_MODE_CBC, $iv));
00091 }
00092
00093 ?>