예제 #1
0
        public byte[] AsByteArray()
        {
            var signatureLengthBytes = new[] {
                (byte)(this.Signature.Length / 0x100),
                (byte)(this.Signature.Length % 0x100),
            };

            var result = new byte[this.Data.Length + this.Signature.Length + 2];

            BufferHelpers.Add(this.Data, result, 0);
            BufferHelpers.Add(this.Signature, result, this.Data.Length);
            BufferHelpers.Add(signatureLengthBytes, result, this.Data.Length + this.Signature.Length);

            return(result);
        }
예제 #2
0
        public static DataWithSignature FromByteArray(byte[] byteArray)
        {
            var signatureLengthBytes = new byte[2];

            BufferHelpers.Extract(byteArray, byteArray.Length - 2, signatureLengthBytes);
            var signatureLength = (signatureLengthBytes[0] * 0x100) + signatureLengthBytes[1];

            var data      = new byte[byteArray.Length - signatureLength - 2];
            var signature = new byte[signatureLength];

            BufferHelpers.Extract(byteArray, 0, data);
            BufferHelpers.Extract(byteArray, data.Length, signature);

            return(new DataWithSignature(data, signature));
        }