modified encrypt and decrypt functionalities