Encode data before sending to the server