I am trying to save a password in a file that I would like to receive later. Hashing is not an option, as I need a password to connect to a remote server for later versions.
The following code works well, but a different output is generated each time, even if the key is the same. This is bad, because when the application shuts down and restarts, I can no longer get the password. How to save passwords in a file and get them later?
public class EncyptDecrypt { static System.Security.Cryptography.TripleDESCryptoServiceProvider keyProv = new System.Security.Cryptography.TripleDESCryptoServiceProvider(); public static System.Security.Cryptography.TripleDESCryptoServiceProvider KeyProvider { get { keyProv.Key = new byte[] { }; return keyProv; } } public static string Encrypt(string text, SymmetricAlgorithm key) { if (text.Equals(string.Empty)) return text;
source share