Пример #1
0
        /// <summary>
        /// simple xor encoding for Gstats,GPSP,GPCM
        /// </summary>
        /// <param name="plaintext"></param>
        /// <param name ="enc0">default encryption string used in GPSP,GPCM</param>
        /// <param name ="enc1">used in GStats</param>
        /// <param name ="enc2">used in GStats</param>
        /// <param name="type"></param>
        /// <returns></returns>
        public static string Encrypt(string plaintext, XorType type)
        {
            string enc0 = "gamespy";
            string enc1 = "GameSpy3D";    // '\0','a','m','e','S','p','y','3','D','\0'
            string enc2 = "Industries";   // { '\0', 'n', 'd', 'u', 's', 't', 'r', 'i', 'e', 's', '\0' }
            string enc3 = "ProjectAphex"; // { '\0','r','o','j','e','c','t','A','p','h','e','x','\0'}
            //string statsfile = "gstats.dat";

            int length = plaintext.Length;

            char[] data  = plaintext.ToCharArray();
            int    index = 0;
            string temp;

            switch (type)
            {
            case XorType.Type0:
                temp = enc0;
                break;

            case XorType.Type1:
                temp = enc1;
                break;

            case XorType.Type2:
                temp = enc2;
                break;

            case XorType.Type3:
                temp = enc3;
                break;

            default:
                temp = enc0;
                break;
            }

            for (int i = 0; length > 0; length--)
            {
                if (i >= temp.Length)
                {
                    i = 0;
                }

                data[index++] ^= temp[i++];
            }

            return(new string(data));
        }
Пример #2
0
        /// <summary>
        /// simple xor encoding for Gstats,GPSP,GPCM
        /// </summary>
        /// <param name="plaintext"></param>
        /// <param name ="enc0">default encryption string used in GPSP,GPCM</param>
        /// <param name ="enc1">used in GStats</param>
        /// <param name ="enc2">used in GStats</param>
        /// <param name="type"></param>
        /// <returns></returns>
        public static byte[] Encode(byte[] plaintext, XorType type)
        {
            string seed0 = "gamespy";
            string seed1 = "GameSpy3D";
            string seed2 = "Industries";
            string seed3 = "ProjectAphex";

            int length = plaintext.Length;
            int index  = 0;

            byte[] temp;
            switch (type)
            {
            case XorType.Type0:
                temp = UniSpyEncoding.GetBytes(seed0);
                break;

            case XorType.Type1:
                temp = UniSpyEncoding.GetBytes(seed1);
                break;

            case XorType.Type2:
                temp = UniSpyEncoding.GetBytes(seed2);
                break;

            case XorType.Type3:
                temp = UniSpyEncoding.GetBytes(seed3);
                break;

            default:
                temp = UniSpyEncoding.GetBytes(seed0);
                break;
            }

            for (int i = 0; length > 0; length--)
            {
                if (i >= temp.Length)
                {
                    i = 0;
                }

                plaintext[index++] ^= temp[i++];
            }

            return(plaintext);
        }
Пример #3
0
        public void SetType(XorType formType, string Key = "")
        {
            lbDecrypt.Visible = false;
            lbEncrypt.Visible = false;
            btnDelete.Visible = false;

            if (formType == XorType.Encrypt)
            {
                lbEncrypt.Visible = true;
                btnDelete.Visible = true;
            }
            else
            {
                lbDecrypt.Visible = true;
            }

            if (!String.IsNullOrEmpty(Key))
            {
                tbKey.Text = Key;
            }
        }
Пример #4
0
 public static string Encrypt(byte[] plaintext, XorType type)
 {
     return(Encrypt(plaintext.ToString(), type));
 }
Пример #5
0
 public static string Encode(string plainText, XorType type)
 {
     return
         (UniSpyEncoding.GetString(
              Encode(UniSpyEncoding.GetBytes(plainText), type)));
 }
Пример #6
0
 public XOREncoding(XorType type)
 {
     EncryptionType = type;
 }