Esempio n. 1
0
        public void Registrate(Account newAccount)
        {
            string allInformationFromFile;
            int    count = 0;

            using (StreamReader sr = new StreamReader(@"Accounts\list.txt", Encoding.Default))
            {
                count = Convert.ToInt32(sr.ReadLine());
                allInformationFromFile = sr.ReadToEnd();
            }
            if (IsSimilarAccount(allInformationFromFile, newAccount) == false)
            {
                MessageBox.Show("Такой логин уже существует!");
                return;
            }
            using (StreamWriter sw = new StreamWriter(@"Accounts\list.txt", false, Encoding.Default))
            {
                count++;
                sw.WriteLine(count.ToString());
                sw.Write(allInformationFromFile);
                Shifrator encrypter = new Shifrator();
                sw.WriteLine(encrypter.Encrypt(newAccount.accountLogin + " " + count, "100501"));

                CreateNewFile(count.ToString());
                MessageBox.Show("Вы успешно зарегестрированы!");
            }
        }
Esempio n. 2
0
 private void ReWrite()
 {
     using (StreamWriter sw = new StreamWriter(@"Accounts\" + saveAccount.ID + ".txt", false, Encoding.Default))
     {
         Shifrator encrypter = new Shifrator();
         for (int j = 0; j < saveAccount.resoursesList.Count(); j++)
         {
             sw.WriteLine(encrypter.Encrypt(saveAccount.resoursesList[j], saveAccount.accountPassword));
         }
     }
 }
Esempio n. 3
0
        public bool IsSimilarAccount(string inputInformation, Account checkedAccount)
        {
            char[]    delimiterChars     = { '\n' };
            string[]  loginsAndPasswords = inputInformation.Split(delimiterChars);
            Shifrator decrypter          = new Shifrator();

            for (int i = 0; i < loginsAndPasswords.Length; i++)
            {
                string str = decrypter.Decrypt(loginsAndPasswords[i], "100501");
                loginsAndPasswords[i] = decrypter.Decrypt(loginsAndPasswords[i], "100501");
            }

            for (int i = 0; i < loginsAndPasswords.Length; i++)
            {
                if (loginsAndPasswords[i].Contains(checkedAccount.accountLogin))
                {
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 4
0
        public int GetID(string inputInformation, Account checkedAccount)
        {
            char[]    delimiterChars     = { '\n' };
            string[]  loginsAndPasswords = inputInformation.Split(delimiterChars);
            Shifrator decrypter          = new Shifrator();

            for (int i = 0; i < loginsAndPasswords.Length; i++)
            {
                string str = decrypter.Decrypt(loginsAndPasswords[i], "100501");
                loginsAndPasswords[i] = str;
            }

            for (int i = 0; i < loginsAndPasswords.Length; i++)
            {
                if (loginsAndPasswords[i].Contains(checkedAccount.accountLogin))
                {
                    string[] cur = loginsAndPasswords[i].Split(' ');
                    return(Convert.ToInt32(cur[1]));
                }
            }
            return(-1);
        }
        public List <string> GetList(int ID, Account account)
        {
            List <string> outputList = new List <string>();
            DirectoryInfo di         = new DirectoryInfo(@"Accounts\");

            FileInfo[] fileInfos = di.GetFiles();
            foreach (var items in fileInfos)
            {
                if (items.Name == ID.ToString() + ".txt")
                {
                    using (StreamReader sr = new StreamReader(items.FullName))
                    {
                        Shifrator sh          = new Shifrator();
                        string    checkString = sr.ReadLine();
                        while (checkString != null && checkString != "")
                        {
                            outputList.Add(sh.Decrypt(checkString, account.accountPassword));
                            checkString = sr.ReadLine();
                        }
                    }
                }
            }
            return(outputList);
        }