x-2 variant: finished encrypt function