What are the recommended approaches for handling encrypted data retrieval and display in PHP, especially when dealing with longblob data types?

When handling encrypted data retrieval and display in PHP, especially with longblob data types, it's important to decrypt the data before displaying it to the user. One recommended approach is to store the encrypted data in the database and decrypt it on the server side before sending it to the client. This ensures that the data remains secure during transmission and only gets decrypted when needed.

// Retrieve the encrypted data from the database
$encryptedData = $row['encrypted_data'];

// Decrypt the data using a decryption function
$decryptedData = decryptFunction($encryptedData);

// Display the decrypted data to the user
echo $decryptedData;