Customizing the encryption of chat texts data to the backend db

We have the requirement to use Vault to encrypt and decrypt the actual chat texts themselves. So basically just before we actually store the chat messages, we will call vault and encrypt it and then store the cipher text.

Likewise, on retrieving the cipher text form the DB, we use vault to decrypt it.

Is this possible via settings or do I need to either create some form of plugin or hack the code.

Thanks in advance.