finished encryption and decryption implementation