Example #1
0
        private static byte[] smethod_11(RegFileInfo regFileInfo_0, byte[] array_0, TaxCard taxCard_1)
        {
            DateTime time;

            errCode = "0000";
            if (taxCard_1 == null)
            {
                taxCard_1 = taxCard_0;
            }
            else
            {
                taxCard_0 = taxCard_1;
            }
            if (array_0.Length != 0x10)
            {
                throw new ArgumentException("验证注册码时,传入的参数不正确");
            }
            byte[] destinationArray = new byte[0x40];
            byte[] bytes            = BitConverter.GetBytes(regFileInfo_0.FileContent.SoftwareType);
            Array.Copy(bytes, 0, destinationArray, 0, bytes.Length);
            byte[] sourceArray = Encoding.ASCII.GetBytes(regFileInfo_0.FileContent.SoftwareID);
            Array.Copy(sourceArray, 0, destinationArray, 2, sourceArray.Length);
            byte[] buffer4 = BitConverter.GetBytes(regFileInfo_0.FileContent.SerialNo);
            Array.Copy(buffer4, 0, destinationArray, 8, buffer4.Length);
            byte[] array = BitConverter.GetBytes(Convert.ToInt32(new string(regFileInfo_0.FileContent.StopDate), 0x10));
            Array.Reverse(array);
            Array.Copy(array, 0, destinationArray, 12, array.Length);
            if (regFileInfo_0.FileContent.SoftwareType == 1)
            {
                destinationArray[0x10] = 1;
            }
            else
            {
                destinationArray[0x10] = 0;
            }
            Array.Copy(regFileInfo_0.FileContent.Verify, 0, destinationArray, 0x18, regFileInfo_0.FileContent.Verify.Length);
            Array.Copy(array_0, 0, destinationArray, 40, array_0.Length);
            byte num = 0;

            for (int i = 0; i < 0x3f; i++)
            {
                num = (byte)(num + destinationArray[i]);
            }
            destinationArray[0x3f] = num;
            TextRegHead head = new TextRegHead {
                Tax_Mw_No = new byte[15]
            };
            string compressCode = taxCard_1.CompressCode;

            if ((regFileInfo_0.FileContent.SoftwareType > 0xff) && compressCode.StartsWith("91"))
            {
                compressCode = "50" + compressCode.Substring(2, compressCode.Length - 2);
            }
            for (int j = 0; j < compressCode.Length; j++)
            {
                if (j >= 15)
                {
                    break;
                }
                head.Tax_Mw_No[j] = (byte)compressCode[j];
            }
            head.Date = new byte[4];
            taxCard_1.GetCardClock(out time, 0);
            byte[] buffer6 = BitConverter.GetBytes(Convert.ToInt32(time.ToString("yyyyMMdd"), 0x10));
            Array.Reverse(buffer6);
            Array.Copy(buffer6, head.Date, 4);
            head.MachinNo = regFileInfo_0.FileContent.BranchNo;
            head.buf      = new byte[0x18];
            Array.Copy(destinationArray, head.buf, 0x18);
            byte[] buffer7 = new byte[0x10];
            byte[] buffer8 = new byte[0x10];
            Xihaa.GenTextRegKey(buffer7, buffer8, ref head);
            Array.Copy(buffer7, 0, destinationArray, 0x18, 0x10);
            byte[] buffer9 = new byte[0x10];
            for (int k = 0; k < 0x10; k++)
            {
                buffer9[k] = (byte)(array_0[k] ^ regFileInfo_0.FileContent.Transfer[k]);
            }
            byte[] buffer10 = new byte[0x10];
            for (int m = 0; m < 0x10; m++)
            {
                buffer10[m] = (byte)(buffer9[m] ^ buffer8[m]);
            }
            Array.Copy(buffer10, 0, destinationArray, 40, 0x10);
            num = 0;
            for (int n = 0; n < 0x3f; n++)
            {
                num = (byte)(num + destinationArray[n]);
            }
            destinationArray[0x3f] = num;
            byte[] buffer11 = null;
            ilog_0.Debug("[注册] 调用校验接口开始");
            string str2 = taxCard_1.CheckRegCode(destinationArray, out buffer11, 0);

            ilog_0.DebugFormat("[注册] 调用校验接口结束,返回值={0}", str2);
            if (ToolUtil.GetReturnErrCode(str2) == 0)
            {
                for (int num9 = 0; num9 < 0x10; num9++)
                {
                    if ((array_0[num9] ^ regFileInfo_0.FileContent.Transfer[num9]) != buffer11[num9])
                    {
                        ilog_0.Debug("验证注册文件失败,第" + num9.ToString() + "位校验失败");
                    }
                }
                ilog_0.Debug("注册文件验证成功");
                return(buffer11);
            }
            ilog_0.Error("注册文件校验失败:接口错误号=" + taxCard_1.ErrCode);
            errCode = taxCard_1.ErrCode;
            return(null);
        }
Example #2
0
 public static extern void GenTextRegKey(byte[] byte_0, byte[] byte_1, ref TextRegHead textRegHead_0);