updated class to accept a key when encrypting and decrypting