Example #1
0
        private string generatePkNormal(ApplicationVersion appV, Client client)
        {
            StringBuilder str = new StringBuilder();

            str.Append("LV");
            str.Append(client.Code);
            str.Append(RandomLetterUpper());
            str.Append(appV.Application.Code);
            str.Append(RandomLetterUpper());
            str.Append(VersionToInt(appV.GetVersion()).ToString("000000"));
            str.Append(RandomLetterUpper());
            str.Append(DateTime.UtcNow.ToDateTimeCE().ToString("yMMdd"));
            str.Append(RandomLetterUpper());
            var r = RandomNumber(1, 99);

            foreach (var c in TTLL.Models.ProductKey.CryptoWord)
            {
                var indx    = Array.IndexOf(TTLL.Models.ProductKey.RandomCryptoSequence, c);
                var newIndx = (indx + r) % TTLL.Models.ProductKey.RandomCryptoSequence.Length;
                if (newIndx < TTLL.Models.ProductKey.RandomCryptoSequence.Length)
                {
                    str.Append(TTLL.Models.ProductKey.RandomCryptoSequence[newIndx]);
                }
                else
                {
                    throw new Exception("error pk");
                }
            }
            str.Append(r.ToString("00"));
            return(str.ToString());
        }
Example #2
0
        private string generatePkTime(ApplicationVersion appV, Client client, TimeSpan endTime)
        {
            StringBuilder str = new StringBuilder();

            str.Append("LT");
            str.Append(client.Code);
            str.Append(RandomLetterUpper());
            str.Append(appV.Application.Code);
            str.Append(RandomLetterUpper());
            str.Append(VersionToInt(appV.GetVersion()).ToString("000000"));
            str.Append(RandomLetterUpper());
            str.Append(DateTime.UtcNow.ToDateTimeCE().ToString("yMMdd"));
            str.Append(RandomLetterUpper());
            var bits = Convert.ToInt32(endTime.TotalHours).ToBoolArray();

            Array.Reverse(bits);
            var bitsG     = groupBits(bits);
            var clearBits = new List <bool>();
            var find      = false;

            foreach (var g in bitsG)
            {
                if (!find)
                {
                    if (g.Contains(true))
                    {
                        clearBits.AddRange(g);
                        find = true;
                    }
                }
                else
                {
                    clearBits.AddRange(g);
                }
            }
            str.Append(getConfidicBits(clearBits));
            return(str.ToString());
        }