@@ -793,8 +793,10 @@ function blowfish_encrypt($data,$secret=null) {
793
793
return $ data ;
794
794
795
795
if (! empty ($ data ) && function_exists ('openssl_encrypt ' ) && in_array (SESSION_CIPHER , openssl_get_cipher_methods ())) {
796
+ $ iv = openssl_random_pseudo_bytes (openssl_cipher_iv_length (SESSION_CIPHER ));
796
797
$ keylen = openssl_cipher_iv_length (SESSION_CIPHER ) * 2 ;
797
- return openssl_encrypt ($ data , SESSION_CIPHER , substr ($ secret ,0 ,$ keylen ));
798
+ $ encrypted = openssl_encrypt ($ data , SESSION_CIPHER , substr ($ secret ,0 ,$ keylen ), $ options =0 , $ iv , $ tag );
799
+ return base64_encode ($ encrypted . ':: ' . $ iv . ':: ' . $ tag );
798
800
}
799
801
800
802
if (function_exists ('mcrypt_module_open ' ) && ! empty ($ data )) {
@@ -855,7 +857,8 @@ function blowfish_decrypt($encdata,$secret=null) {
855
857
856
858
if (! empty ($ encdata ) && function_exists ('openssl_encrypt ' ) && in_array (SESSION_CIPHER , openssl_get_cipher_methods ())) {
857
859
$ keylen = openssl_cipher_iv_length (SESSION_CIPHER ) * 2 ;
858
- return trim (openssl_decrypt ($ encdata , SESSION_CIPHER , substr ($ secret ,0 ,$ keylen )));
860
+ list ($ encryptedData , $ iv , $ tag ) = explode (':: ' , base64_decode ($ encdata ), 3 );
861
+ return trim (openssl_decrypt ($ encryptedData , SESSION_CIPHER , substr ($ secret ,0 ,$ keylen ), $ options =0 , $ iv , $ tag ));
859
862
}
860
863
861
864
if (function_exists ('mcrypt_module_open ' ) && ! empty ($ encdata )) {
0 commit comments