diff --git a/lib/functions.php b/lib/functions.php index 87d0bf6..381a434 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -745,6 +745,16 @@ function blowfish_encrypt($data,$secret=null) { if (! trim($secret)) return $data; + if (function_exists('mcrypt_module_open')) { + $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 @@ -790,6 +800,16 @@ function blowfish_decrypt($encdata,$secret=null) { if (! trim($secret)) return $encdata; + if (function_exists('mcrypt_module_open')) { + $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