SF Feature #2900545 - blowfish using mcrypt
This commit is contained in:
parent
e083f5f8b5
commit
775e6f40d4
@ -745,6 +745,16 @@ function blowfish_encrypt($data,$secret=null) {
|
|||||||
if (! trim($secret))
|
if (! trim($secret))
|
||||||
return $data;
|
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'))
|
if (file_exists(LIBDIR.'blowfish.php'))
|
||||||
require_once LIBDIR.'blowfish.php';
|
require_once LIBDIR.'blowfish.php';
|
||||||
else
|
else
|
||||||
@ -790,6 +800,16 @@ function blowfish_decrypt($encdata,$secret=null) {
|
|||||||
if (! trim($secret))
|
if (! trim($secret))
|
||||||
return $encdata;
|
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'))
|
if (file_exists(LIBDIR.'blowfish.php'))
|
||||||
require_once LIBDIR.'blowfish.php';
|
require_once LIBDIR.'blowfish.php';
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user