Skip to content

Commit

Permalink
Extend the PHP 7.1 validation to the encrypt and decrypt functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
vaurdan committed Jul 8, 2021
1 parent ffa394f commit 08527eb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions includes/push-syndicate-encryption.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ function push_syndicate_encrypt( $data ) {
// Will most likely break backwards compatibility with older keys
// https://stackoverflow.com/questions/49997338/mcrypt-rijndael-256-to-openssl-aes-256-ecb-conversion

// Backwards compatibility with PHP < 7.2.
if ( function_exists( 'mcrypt_encrypt' ) ) {
// Backwards compatibility with PHP < 7.1. Use mcrypt instead.
if ( version_compare( PHP_VERSION, '7.1', '<' ) ) {
// @codingStandardsIgnoreStart
$data = serialize( $data );
return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5(PUSH_SYNDICATE_KEY), $data, MCRYPT_MODE_CBC, md5(md5(PUSH_SYNDICATE_KEY))));
Expand All @@ -45,8 +45,8 @@ function push_syndicate_encrypt( $data ) {

function push_syndicate_decrypt( $data, $associative = true ) {

// Backwards compatibility with PHP < 7.2.
if ( function_exists( 'mcrypt_encrypt' ) ) {
// Backwards compatibility with PHP < 7.1. Use mcrypt instead.
if ( version_compare( PHP_VERSION, '7.1', '<' ) ) {
// @codingStandardsIgnoreStart
$data = rtrim( mcrypt_decrypt( MCRYPT_RIJNDAEL_256, md5( PUSH_SYNDICATE_KEY ), base64_decode( $data ), MCRYPT_MODE_CBC, md5( md5( PUSH_SYNDICATE_KEY ) ) ), "\0" );
if ( ! $data ) {
Expand Down

0 comments on commit 08527eb

Please sign in to comment.