Handle encryption and decryption results correctly.
More error handling is still needed, though.