예제 #1
0
        // Username, Password, File name (Usually @"./AEUsers"), game ("minecraft")
        // possible multiple logins idea, return multiple dictionarys with array
        // also look for name of login as well. before saving.
        public static void writeLoginFile(string accName, string accPass, string location, string game, bool auto)
        {
            string saveString = StringCipher.Encrypt(game + ":" + accName + ":" + accPass + ":" + auto.ToString(), StringCipher.uniqueMachineId());
            bool   gameSaved  = false;

            if (File.Exists(location))
            {
                string[] EncryptedStrings = File.ReadAllLines(location);
                for (int i = 0; i < EncryptedStrings.Length; i++)
                {
                    if (EncryptedStrings[i] != "")
                    {
                        string   DecryptedString = StringCipher.Decrypt(EncryptedStrings[i], StringCipher.uniqueMachineId());
                        string[] lineArray       = DecryptedString.Split(new char[] { ':' }, 4);
                        if (lineArray[0] == game && lineArray[1] == accName)
                        {
                            EncryptedStrings[i] = saveString;
                            gameSaved           = true;
                        }
                    }
                }
                if (gameSaved == false)
                {
                    Array.Resize(ref EncryptedStrings, EncryptedStrings.Length + 1);
                    EncryptedStrings[EncryptedStrings.Length - 1] = saveString;
                }
                File.WriteAllLines(location, EncryptedStrings);
            }
            else
            {
                File.WriteAllText(location, saveString);
            }
        }
예제 #2
0
        // Game "minecraft", File name @"./AEUsers"
        // possible multiple logins idea, array within array
        //
        // For example: Step by step
        // readline
        // its "minecraft" add to array of dictonary key "minecraft"
        // next line
        // its "minecraft" add to array of diconary key "minecraft"
        // Nothing more? Return array?
        public static string[,] readLoginFileAll(string game, string location)
        {
            string[] lineArray = { "false" };
            string[,] multiLineA = { { "false", "false", "false", "false" } };
            int y = 4;

            if (File.Exists(location))
            {
                string[] EncryptedStrings = File.ReadAllLines(location);
                for (int x = 0; x < EncryptedStrings.Length; x++)
                {
                    if (EncryptedStrings[x] != "")
                    {
                        string DecryptedString = StringCipher.Decrypt(EncryptedStrings[x], StringCipher.uniqueMachineId());
                        lineArray = DecryptedString.Split(new char[] { ':' }, 4);
                        if (lineArray[0] == game)
                        {
                            for (int i = 0; i < lineArray.Length; i++)
                            {
                                if (x >= multiLineA.GetLength(0))
                                {
                                    int z = multiLineA.GetLength(0) + 1;
                                    ResizeArray(ref multiLineA, z, y);
                                }
                                multiLineA[x, i] = lineArray[i];
                            }
                        }
                    }
                }
            }
            return(multiLineA);
        }
예제 #3
0
 public static string[] readLoginFileUser(string game, string location, string accName)
 {
     // Change this to make User only requesting.
     string[] lineArray = { "false" };
     if (File.Exists(location))
     {
         string[] EncryptedStrings = File.ReadAllLines(location);
         for (int x = 0; x < EncryptedStrings.Length; x++)
         {
             if (EncryptedStrings[x] != "")
             {
                 string DecryptedString = StringCipher.Decrypt(EncryptedStrings[x], StringCipher.uniqueMachineId());
                 lineArray = DecryptedString.Split(new char[] { ':' }, 4);
                 if (lineArray[0] == game && lineArray[1] == accName)
                 {
                     break;
                 }
             }
         }
     }
     return(lineArray);
 }
예제 #4
0
 // possible multiple logins idea, return multiple dictionarys with array
 // also look for name of login as well. before saving.
 public static void removeLoginLine(string location, string game, string accName)
 {
     if (File.Exists(location))
     {
         string[] EncryptedStrings    = File.ReadAllLines(location);
         string[] NewEncryptedStrings = { "" };
         int      x = 0;
         for (int i = 0; i < EncryptedStrings.Length; i++)
         {
             if (EncryptedStrings[i] != "")
             {
                 string   DecryptedString = StringCipher.Decrypt(EncryptedStrings[i], StringCipher.uniqueMachineId());
                 string[] lineArray       = DecryptedString.Split(new char[] { ':' }, 4);
                 if (lineArray[0] != game && lineArray[1] != accName)
                 {
                     if (i - x >= NewEncryptedStrings.Length)
                     {
                         Array.Resize(ref NewEncryptedStrings, NewEncryptedStrings.Length + 1);
                     }
                     NewEncryptedStrings[i - x] = EncryptedStrings[i];
                 }
                 else
                 {
                     x++;
                 }
             }
             else
             {
                 x++;
             }
         }
         File.WriteAllLines(location, NewEncryptedStrings);
     }
 }