예제 #1
0
        //发送包
        public void SendPackage(byte[] data)
        {
            byte[] sha = SignTool.ComputeSHA256(data, 0, data.Length);
            string key = SignTool.Hex2String(sha, 0, sha.Length);

            datapool[key] = 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.Length);

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

            SendMessage(msg, true);
        }
예제 #2
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);
        }