private byte[] FormatKeyPadMessage(string xmlMessage)
{
try
{
byte[] byteMessage = new byte[4096];
byte[] startChar = new byte[1];
byte[] endChar = new byte[1];
startChar[0] = 0x02;
endChar[0] = 0x03;
byteMessage = StrToByteArray(xmlMessage);
int arraySize = byteMessage.Length + 3;
var ms = new MemoryStream(new byte[arraySize], 0, arraySize, true, true);
ms.Write(startChar, 0, 1);
ms.Write(byteMessage, 0, byteMessage.Length);
ms.Write(endChar, 0, 1);
byte[] mergedMessage = ms.GetBuffer();
return mergedMessage;
}
catch (Exception ex)
{
return null;
}
}
|