Clean up encrypt function.