Implement encrypt and decrypt functions.