Пример #1
0
        /// <summary>
        /// Returns all accounts available in a list
        /// </summary>
        /// <returns>Returns list of accounts</returns>
        public static List <Config.LoadSteamGuardAccount> GetAllAccounts()
        {
            /*Locate the .SGA save files*/
            var           sgaList = new List <Config.LoadSteamGuardAccount>();
            DirectoryInfo info    = new DirectoryInfo(Path.Combine(Application.StartupPath, "SGAFiles"));

            FileInfo[] files = info.GetFiles("*.SGA");

            foreach (FileInfo file in files)
            {
                bool skipDeserialize = false;
                try
                {
                    string contentStr = File.ReadAllText(file.FullName);
                    if (contentStr.Length > 0)
                    {
                        /*N1 way to determine if it's hashed*/
                        if (contentStr.EndsWith("="))
                        {
                            /*If user skips password the secret will be empty, so don't bother with these accounts*/
                            if (Crypto.crySecret.Length > 0)
                            {
                                contentStr = Crypto.DecryptStringAES(contentStr);
                            }
                            else
                            {
                                skipDeserialize = true;
                            }
                        }

                        /*Try to deserialize content to account class*/
                        var accountHolder         = new Config.LoadSteamGuardAccount();
                        SteamGuardAccount account = null;
                        if (!skipDeserialize)
                        {
                            /*We don't want to attempt to deserialize this string, but we still want to add the other information*/
                            account = JsonConvert.DeserializeObject <SteamGuardAccount>(contentStr);
                            accountHolder.account = account;
                        }

                        /*Load the rest of information about the file*/
                        accountHolder.loaded   = (account != null);
                        accountHolder.filename = Path.GetFileNameWithoutExtension(file.Name);

                        /*Add account holder to list that we will return*/
                        sgaList.Add(accountHolder);
                    }
                }
                catch (Exception ex)
                {
                    /*Whoops - what happend here?*/
                    MessageBox.Show(ex.ToString());
                }
            }

            return(sgaList);
        }
Пример #2
0
        /// <summary>
        /// Returns all accounts available in a list
        /// </summary>
        /// <returns>Returns list of accounts</returns>
        public static List<Config.LoadSteamGuardAccount> GetAllAccounts()
        {
            /*Locate the .SGA save files*/
            var sgaList = new List<Config.LoadSteamGuardAccount>();
            DirectoryInfo info = new DirectoryInfo(Path.Combine(Application.StartupPath, "SGAFiles"));
            FileInfo[] files = info.GetFiles("*.SGA");

            foreach(FileInfo file in files)
            {
                bool skipDeserialize = false;
                try
                {
                    string contentStr = File.ReadAllText(file.FullName);
                    if (contentStr.Length > 0)
                    {
                        /*N1 way to determine if it's hashed*/
                        if (contentStr.EndsWith("="))
                        {
                            /*If user skips password the secret will be empty, so don't bother with these accounts*/
                            if (Crypto.crySecret.Length > 0)
                            {
                                contentStr = Crypto.DecryptStringAES(contentStr);
                            }
                            else
                            {
                                skipDeserialize = true;
                            }
                        }

                        /*Try to deserialize content to account class*/
                        var accountHolder = new Config.LoadSteamGuardAccount();
                        SteamGuardAccount account = null;
                        if (!skipDeserialize)
                        {
                            /*We don't want to attempt to deserialize this string, but we still want to add the other information*/
                            account = JsonConvert.DeserializeObject<SteamGuardAccount>(contentStr);
                            accountHolder.account = account;
                        }

                        /*Load the rest of information about the file*/
                        accountHolder.loaded = (account != null);
                        accountHolder.filename = Path.GetFileNameWithoutExtension(file.Name);

                        /*Add account holder to list that we will return*/
                        sgaList.Add(accountHolder);
                    }
                }
                catch(Exception ex)
                {
                    /*Whoops - what happend here?*/
                    MessageBox.Show(ex.ToString());
                }
            }

            return sgaList;
        }