What are some potential issues with using the mcrypt_encrypt function in PHP?

One potential issue with using the mcrypt_encrypt function in PHP is that it has been deprecated since PHP 7.1 and removed in PHP 7.2 due to security vulnerabilities and lack of maintenance. To solve this issue, it is recommended to use the OpenSSL extension in PHP for encryption and decryption purposes.

// Example of using the OpenSSL extension for encryption
function encryptData($data, $key) {
    $iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length('aes-256-cbc'));
    $encrypted = openssl_encrypt($data, 'aes-256-cbc', $key, 0, $iv);
    return base64_encode($iv . $encrypted);
}

// Example of using the OpenSSL extension for decryption
function decryptData($data, $key) {
    $data = base64_decode($data);
    $iv = substr($data, 0, openssl_cipher_iv_length('aes-256-cbc'));
    $encrypted = substr($data, openssl_cipher_iv_length('aes-256-cbc'));
    return openssl_decrypt($encrypted, 'aes-256-cbc', $key, 0, $iv);
}