Exemplo n.º 1
0
 public static void ReadKey()
 {
     using (var fstream = SecureFileStream.OpenWithStream("settings", "keeperdata", FileMode.Open, FileAccess.Read))
         using (var reader = new StreamReader(fstream, Encoding.Unicode))
         {
             AES_256.aeskey = Encoding.ASCII.GetBytes(reader.ReadToEnd());
         }
 }
Exemplo n.º 2
0
        public static void WriteKey()
        {
            if (File.Exists("settings"))
            {
                return;
            }

            using (var fstream = SecureFileStream.OpenWithStream("settings", "keeperdata", FileMode.Create, FileAccess.Write))
                using (var writer = new StreamWriter(fstream, Encoding.Unicode))
                {
                    var r = new RandomPasswordAndCopy();
                    writer.Write(r.GetRandomPassword());
                }
        }