0

I used following codes to encrypt and decrypt the strings in php. I recently upgraded my server and now i can see that the codes i use is depreciated. Encryption code is hardcoded on my app so i need to decrypt on the server. Please provide the alternative to both encrypt and decrypt

Code for encryption.

function encrypt($data = '', $key = 'chiperbase65enus')
    {
    $encrypted = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $data, MCRYPT_MODE_CBC, 'chiperbase65enus');
        return base64_encode($encrypted);
    }

And for decryption is below. I dont actually need encryption anymore but decryption is the must.

function decrypt($data = '', $key = 'chiperbase65enus')
    {
        $decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, base64_decode($data), MCRYPT_MODE_CBC,'chiperbase65enus');
        return rtrim($decrypted, "\0");
    }
Sujan D Stc
  • 27
  • 1
  • 5
  • 1
    Possible duplicate of [mcrypt is deprecated, what is the alternative?](https://stackoverflow.com/questions/41272257/mcrypt-is-deprecated-what-is-the-alternative) – Evil_skunk Nov 17 '19 at 17:15

1 Answers1

1
 $decrypted = openssl_decrypt(base64_decode($encrypted_string), "AES-128-CBC", "chiperbase65enus",OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, "chiperbase65enus");

I found the solution...

Sujan D Stc
  • 27
  • 1
  • 5