Exemple #1
0
        public void SendDataBlock(DataBlock data)
        {
            Message msg = new Message();

            msg.tag1  = 0x01;                   //0字节
            msg.tag2  = 0x01;                   //1字节
            msg.msgid = SignTool.RandomShort(); // 2 3 字节

            //4~7 字节
            var byteLength = BitConverter.GetBytes((UInt32)data.data.Length);

            for (var i = 0; i < 4; i++)
            {
                msg.data[i] = byteLength[i];
            }
            var sha = SignTool.HexString2Bytes(data.sha256);

            //8 到39 字节
            for (var i = 0; i < 32; i++)
            {
                msg.data[i + 4] = sha[i];
            }

            SendMessage(msg, true);
        }
Exemple #2
0
        public void writeHash256(int pos, string hash)
        {
            var b = SignTool.HexString2Bytes(hash);

            for (var i = 0; i < b.Length; i++)
            {
                data[pos + i] = b[i];
            }
        }
Exemple #3
0
        public bool Check()
        {
            byte[] hashdata = SignTool.HexString2Bytes(sha256);
            var    hash     = SignTool.ComputeSHA256(data, 0, data.Length);
            var    hashstr  = SignTool.Bytes2HexString(hash, 0, hash.Length);

            match = (hashstr.ToUpper() == sha256.ToUpper());
            return(match);
        }