Encrypt function modified