Are there alternative methods in PHP for text encryption that allow for decryption, and if so, what are they?

One alternative method for text encryption in PHP that allows for decryption is using the `openssl_encrypt` and `openssl_decrypt` functions. These functions utilize the OpenSSL library to encrypt and decrypt data. By specifying a cipher method, encryption key, and initialization vector (IV), you can securely encrypt and decrypt text in PHP.

// Encryption
function encryptText($text, $key) {
    $cipher = "aes-256-cbc";
    $ivlen = openssl_cipher_iv_length($cipher);
    $iv = openssl_random_pseudo_bytes($ivlen);
    $encrypted = openssl_encrypt($text, $cipher, $key, 0, $iv);
    return base64_encode($iv . $encrypted);
}

// Decryption
function decryptText($text, $key) {
    $cipher = "aes-256-cbc";
    $ivlen = openssl_cipher_iv_length($cipher);
    $text = base64_decode($text);
    $iv = substr($text, 0, $ivlen);
    $encrypted = substr($text, $ivlen);
    return openssl_decrypt($encrypted, $cipher, $key, 0, $iv);
}

$key = "secret_key";
$text = "Hello, World!";
$encryptedText = encryptText($text, $key);
echo "Encrypted Text: " . $encryptedText . "\n";

$decryptedText = decryptText($encryptedText, $key);
echo "Decrypted Text: " . $decryptedText . "\n";