Write data.
Encrypts and packs data with the specified length dataLen into a single record and sends the record.