created encrypt and decrypt function