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()); } }
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()); } }