コード例 #1
0
        /// <summary>
        /// Ben deshifrimin e numrit serial qe eshte i ruajtur ne rregjistra nga versioni i plote ne
        /// versionin DEMO
        /// </summary>
        /// <returns>numrin serial te deshifruar</returns>
        private static string DecryptKeyFull()
        {
            try
            {
                int      length  = Convert.ToInt32(GetKeyValue("Vlera2"));
                string   keyFull = GetKeyValue(path, name);
                Encoding ascii   = Encoding.ASCII;
                int      nr;
                // Bejme deshifrimin e numrit te dhomave qe jane ne program
                string nrDhomash        = keyFull.Substring(keyFull.Length - length, length);
                string nrDhomashDec     = "";
                Byte[] encodedRoomCount = ascii.GetBytes(nrDhomash);
                foreach (Byte b in encodedRoomCount)
                {
                    nr = Algebra.GetIndex(Convert.ToChar(b));
                    // Bejme kete veprim: ((nr + 6) / 8) - 9
                    nr            = Algebra.Substract(Algebra.Divide(Algebra.Sum(nr, 6, 59), 8, 59), 9, 59);
                    nrDhomashDec += Algebra.GetChar(nr).ToString();
                }

                // Bejme deshifrimin e kohes se ngarkimit te sistemit
                string loadedSystemTime = keyFull.Substring(keyFull.Length - (4 + length), 4);
                string systemTimeDec    = "";
                Byte[] systemTime       = ascii.GetBytes(loadedSystemTime);
                foreach (Byte b in systemTime)
                {
                    nr = Algebra.GetIndex(Convert.ToChar(b));
                    // Bejme kete veprim: ((nr + 8) / 3) - 15
                    nr             = Algebra.Substract(Algebra.Divide(Algebra.Sum(nr, 6, 59), 3, 59), 15, 59);
                    systemTimeDec += Algebra.GetChar(nr).ToString();
                }

                // Bejme deshifrimin e numrit serial te sistemit
                string systemSerial        = keyFull.Substring(0, 10);
                string systemSerialDec     = "";
                Byte[] encodedSystemSerial = ascii.GetBytes(systemSerial);
                foreach (Byte b in encodedSystemSerial)
                {
                    nr = Algebra.GetIndex(Convert.ToChar(b));
                    // Bejme kete veprim: ((nr - 7) / 10) + 2
                    nr = Algebra.Sum(Algebra.Divide(Algebra.Substract(nr, 7, 59), 10, 59), 2, 59);
                    systemSerialDec += Algebra.GetChar(nr).ToString();
                }

                // Bejme deshifrimin e numrit serial te hard diskut
                string hardDiskSerial    = keyFull.Substring(10, keyFull.Length - (4 + length + 10));
                string hardDiskSerialDec = "";
                Byte[] encodedHDSerial   = ascii.GetBytes(hardDiskSerial);
                int    i = 0;
                foreach (Byte b in encodedHDSerial)
                {
                    nr = Algebra.GetIndex(Convert.ToChar(b));
                    // Bejme kete veprim: ((nr - ((i * 3) + 3) / 7) - 6
                    nr = Algebra.Substract(Algebra.Divide(Algebra.Substract(nr,
                                                                            Algebra.Sum(Algebra.Multiply(i, 3, 59), 3, 59), 59), 7, 59), 6, 59);
                    hardDiskSerialDec += Algebra.GetChar(nr).ToString();
                    i++;
                }
                int numerDhomash = Convert.ToInt32(nrDhomashDec);
                numerDhomash = (numerDhomash + 4) * 3;
                // Tani bashkojme vlerat e gjetura nga deshifrimet e mesiperme dhe e kthejme kete vlere
                return(systemSerialDec + hardDiskSerialDec + systemTimeDec + "-" + numerDhomash.ToString());
            }
            catch (Exception ex)
            {
                return("");
            }
        }
コード例 #2
0
        private static string EncryptKeyFull()
        {
            string   keyDemo = GetKeyValue(path, name);
            Encoding ascii   = Encoding.ASCII;

            string[] split = keyDemo.Split(new char[] { '-' });
            // Nese gjendet me shume se nje vize atehere vlerat e rregjistrave nuk jane ne rregull.
            // Ne kete rast kthe null
            if (split.Length != 2)
            {
                return(null);
            }
            // Nese numri i dhomave nuk plotpjesetohet me 3 atehere ai eshte modifikuar jashte programit.
            // Kthe vlere null edhe ne kete rast
            if ((Convert.ToInt32(split[1]) % 3) != 0)
            {
                return(null);
            }
            int roomCount = (Convert.ToInt32(split[1]) / 3) - 4;

            // Tani bejme kriptimin e numrit te dhomave
            Byte[] encodedRoomCount = ascii.GetBytes(roomCount.ToString());
            int    nr;
            string nrDhomash = "";

            foreach (Byte b in encodedRoomCount)
            {
                nr = Algebra.GetIndex(Convert.ToChar(b));
                // Bejme kete veprim: ((nr + 9) * 8) - 6 ne Z(59)
                nr         = Algebra.Substract(Algebra.Multiply(Algebra.Sum(nr, 9, 59), 8, 59), (6), 59);
                nrDhomash += Algebra.GetChar(nr).ToString();
            }

            // Bejme kriptimin e kohes kur eshte ngarkuar sistemi
            string loadedSystemTime = split[0].Substring(split[0].Length - 4, 4);

            Byte[] systemTime        = ascii.GetBytes(loadedSystemTime);
            string encodedSystemTime = "";

            foreach (Byte b in systemTime)
            {
                nr = Algebra.GetIndex(Convert.ToChar(b));
                // Bejme kete veprim: ((nr + 15) * 3) - 8
                nr = Algebra.Substract(Algebra.Multiply(Algebra.Sum(nr, 15, 59), 3, 59), 6, 59);
                encodedSystemTime += Algebra.GetChar(nr).ToString();
            }

            // Bejme kriptimin e numrit serial te Windows-it
            string systemSerial = split[0].Substring(0, 10);

            Byte[] encodedSystemSerial = ascii.GetBytes(systemSerial);
            string systemSerialEnc     = "";

            foreach (Byte b in encodedSystemSerial)
            {
                nr = Algebra.GetIndex(Convert.ToChar(b));
                // Bejme kete veprim: ((nr - 2) * 10) + 7
                nr = Algebra.Sum(Algebra.Multiply(Algebra.Substract(nr, 2, 59), 10, 59), 7, 59);
                systemSerialEnc += Algebra.GetChar(nr);
            }

            // Bejme kriptimin e ID-se se hardDiskut
            string hardDisk = split[0].Substring(10, split[0].Length - 14);

            Byte[] encodedHardDiskID = ascii.GetBytes(hardDisk);
            string hardDiskIDEnc     = "";
            int    i = 0;

            foreach (Byte b in encodedHardDiskID)
            {
                nr = Algebra.GetIndex(Convert.ToChar(b));
                // Bejme kete veprim: ((nr + 6) * 7) + ((i * 3) + 3)
                nr = Algebra.Sum(Algebra.Multiply(Algebra.Sum(nr, 6, 59), 7, 59),
                                 Algebra.Sum(Algebra.Multiply(i, 3, 59), 3, 59), 59);
                hardDiskIDEnc += Algebra.GetChar(nr);
                i++;
            }

            // Ne kete pike vendosim te gjitha vlerat e nxjerra nga kriptimi, bashke
            return(systemSerialEnc + hardDiskIDEnc + encodedSystemTime + nrDhomash);
            //			return keyDemo;
        }