コード例 #1
0
        public static DistanceDataParameter DistanceData(byte[] by)
        {
            DistanceDataParameter parameter = new DistanceDataParameter();

            parameter.FunctionByte          = HexadecimalConversion.HexToInt(by[18], by[19]);
            parameter.FunctionByteParameter = DistanceFunctionByte(parameter.FunctionByte);
            parameter.Count = HexadecimalConversion.HexToInt(by[20], by[21], by[22], by[23]);
            return(parameter);
        }
コード例 #2
0
ファイル: DataValidation.cs プロジェクト: wpmyj/CbznSystem
        private bool ContrastValidation(byte[] by, int contrastvalue, int start)
        {
            int count = 0;

            byte[] contrastdata = HexadecimalConversion.IntToAscii(contrastvalue);
            foreach (byte item in contrastdata)
            {
                if (by[start + count] != item)
                {
                    return(false);
                }
                count++;
            }
            return(true);
        }
コード例 #3
0
        public static ParsingParameter ParsingContent(byte[] by)
        {
            ParsingParameter parameter = new ParsingParameter();

            parameter.FunctionAddress = by[1];
            parameter.DeviceAddress   = (byte)HexadecimalConversion.HexToInt(by[2], by[3]);
            parameter.Command         = (byte)HexadecimalConversion.HexToInt(by[4], by[5]);
            byte[] newby = new byte[by.Length - 9];
            if (newby.Length > 0)
            {
                Array.Copy(by, 6, newby, 0, newby.Length);
            }
            parameter.DataContent = newby;
            return(parameter);
        }
コード例 #4
0
        public byte[] Integration(byte[] datacontent)
        {
            List <byte> bylist = new List <byte>();

            bylist.Add((byte)Head);
            bylist.Add((byte)FunctionAddress);
            bylist.AddRange(HexadecimalConversion.IntToAscii(DeviceAddress));
            bylist.AddRange(HexadecimalConversion.IntToAscii(Command));
            if (datacontent != null)
            {
                bylist.AddRange(datacontent);
            }
            int xor = DataValidation.Xor(bylist);

            bylist.AddRange(HexadecimalConversion.IntToAscii(xor));
            bylist.Add((byte)End);
            return(bylist.ToArray());
        }
コード例 #5
0
        public static DistanceParameter DistanceParsingContent(byte[] by)
        {
            DistanceParameter parameter = new DistanceParameter();

            parameter.Command          = HexadecimalConversion.HexToInt(by[0], by[1]);
            parameter.AuxiliaryCommand = HexadecimalConversion.HexToInt(by[2], by[3]);
            if (parameter.AuxiliaryCommand != 8)
            {
                if (parameter.Command == 10 || parameter.Command == 11 || parameter.Command == 13 || parameter.Command == 26 || parameter.Command == 27)
                {
                    parameter.CardNumber = Encoding.ASCII.GetString(by, 4, 6);
                    if (parameter.Command == 10 || parameter.Command == 13 || parameter.Command == 26)
                    {
                        parameter.Type          = HexadecimalConversion.HexToInt(by[10], by[11]);
                        parameter.TypeParameter = DistanceType(parameter.Type);
                    }
                }
            }
            return(parameter);
        }
コード例 #6
0
 public static long TemporaryContent(byte[] by)
 {
     if (by.Length == 1 || by.Length == 3)
     {
         return(by[0]);
     }
     if (@by.Length == 2)
     {
         return(HexadecimalConversion.HexToInt(@by[0], @by[1]));
     }
     if (@by.Length == 15)
     {
         return(HexadecimalConversion.HexToInt(@by[11], @by[12]));
     }
     if (@by.Length == 22)
     {
         string str   = Encoding.ASCII.GetString(@by);
         int    index = str.LastIndexOf("0x", StringComparison.Ordinal);
         str = str.Substring(index + 4, 8);
         return(Convert.ToInt32(str, 16));
     }
     return(-1);
 }