/// <summary> /// Get mailpassword from registry entry /// </summary> /// <param name="c"></param> /// <returns></returns> public static string GetRegistryPassword(Credentials c) { using (RegistryKey k = Registry.CurrentUser.OpenSubKey("Software")?.OpenSubKey("Bestellsoftware")) { return(Crypting.DecryptString(k.GetValue("Passwort").ToString(), SecureStringHandler.SecureStringToString(c.Password))); //Rückgabe des entschlüsselten Passworts } }
/// <summary> /// Save mailpassword encrypted in registry /// </summary> /// <param name="mailpswd"></param> /// <param name="pswd"></param> public void WritePasswortRegistry(string mailpswd, string pswd) { RegistryKey ps = Registry.CurrentUser.OpenSubKey("Software", true); ps.CreateSubKey("Bestellsoftware"); ps = ps.OpenSubKey("Bestellsoftware", true); //Mail Passwort wird mit dem Benutzerpasswort verschlüsselt und in der Registry gespeichert ps.SetValue("Passwort", Crypting.EncryptString(mailpswd, pswd)); ps.Close(); }