Exemple #1
0
        public static void WriteAToken(string aToken, bool isEncrypted, string pass)
        {
            string path = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\MaiksLauncher\";

            if (File.Exists(path + @"ATokenEncrypted.mat") == false || Directory.Exists(path) == false && isEncrypted == true)
            {
                Directory.CreateDirectory(path);
                File.CreateText(path + @"ATokenEncrypted.mat");
            }
            File.WriteAllText(path + @"ATokenEncrypted.mat", String.Empty);
            TextWriter tw = new StreamWriter(path + @"ATokenEncrypted.mat", true);

            tw.WriteLine(EncryptorDecryptor.Encrypt(aToken, pass));
            tw.Close();
        }
Exemple #2
0
        public static string ReadEncryptedAToken(string decryptPass)
        {
            string path            = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\MaiksLauncher\";
            string ATokenDecrypted = "";

            try
            {
                try
                {
                    StreamReader sr = new StreamReader(path + @"ATokenEncrypted.txt");
                    string       ATokenEncrypted = sr.ReadToEnd();
                    ATokenDecrypted = EncryptorDecryptor.Decrypt(ATokenEncrypted, decryptPass);
                }
                catch (IOException e)
                {
                    ATokenDecrypted = "IOError";
                }
            }
            catch (Exception e)
            {
                ATokenDecrypted = "Invalid file";
            }
            return(ATokenDecrypted);
        }