@@ -793,8 +793,10 @@ function blowfish_encrypt($data,$secret=null) {
793793 return $ data ;
794794
795795 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 ));
796797 $ 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 );
798800 }
799801
800802 if (function_exists ('mcrypt_module_open ' ) && ! empty ($ data )) {
@@ -855,7 +857,8 @@ function blowfish_decrypt($encdata,$secret=null) {
855857
856858 if (! empty ($ encdata ) && function_exists ('openssl_encrypt ' ) && in_array (SESSION_CIPHER , openssl_get_cipher_methods ())) {
857859 $ 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 ));
859862 }
860863
861864 if (function_exists ('mcrypt_module_open ' ) && ! empty ($ encdata )) {
0 commit comments