Encode data before send