Exemple #1
0
        public static int GetUseTick(string info, string key, bool isdate)
        {
            int count = 0, error = 0;

            if (key.Length > 50)
            {
                string mw16   = MyEncrypt.GetMd5_16(info, true);
                string mw32   = MyEncrypt.GetMD5(info);
                string qian8  = key.Substring(0, 8);
                string num    = MyEncrypt.FanZhuan(key.Substring(8, 4));
                string zhong8 = key.Substring(12, 8);
                string date   = MyEncrypt.DecryptB(MyEncrypt.FanZhuan(key.Substring(20, key.Length - 28)));
                mw16 = MyEncrypt.getRjCode(NumerStrToList(qian8), MyEncrypt.split(mw16));
                mw32 = MyEncrypt.getRjCode(NumerStrToList(zhong8), MyEncrypt.split(mw32));
                string str1  = mw16 + mw32;
                string str2  = key.Substring(key.Length - 8, 8);
                string today = DateTime.Now.Year + bu0(DateTime.Now.Month) + bu0(DateTime.Now.Day);
                Regex  r     = new Regex(@"^[0-9]*$");
                int    d1    = int.Parse(date);
                int    d2    = int.Parse(today);
                if (!r.IsMatch(qian8))
                {
                    error++;
                }
                if (!r.IsMatch(zhong8))
                {
                    error++;
                }
                if (!r.IsMatch(date))
                {
                    error++;
                }
                if (!str1.Equals(str2))
                {
                    error++;
                }
                if (d1 > d2)
                {
                    error++;
                }
                if (isdate && (d2 - d1) > 1)
                {
                    error++;
                }
                if (error == 0)
                {
                    num   = MyEncrypt.CharToNumerStr(num);
                    count = int.Parse(num);
                }
                else
                {
                    count = count - error;
                }
            }
            return(count);
        }