how to encrypt and decrypt password,,,, i am using c# visual studio 2012 front end and sql server 2005 back end thank u
Password encryption
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Guest UserRank #258 · 9.8K pointsPosted Aug 22, 2014, 4:21 PM EDT
public string Encrypt(string plainText) { if (plainText == null) throw new ArgumentNullException("plainText"); //encrypt data var data = Encoding.Unicode.GetBytes(plainText); byte[] encrypted = ProtectedData.Protect(data, null, Scope); //return as base64 string return Convert.ToBase64String(encrypted); } public string Decrypt(string cipher) { if (cipher == null) throw new ArgumentNullException("cipher"); //parse base64 string byte[] data = Convert.FromBase64String(cipher); //decrypt data byte[] decrypted = ProtectedData.Unprotect(data, null, Scope); return Encoding.Unicode.GetString(decrypted); }Guest UserRank #258 · 9.8K pointsPosted Aug 22, 2014, 4:22 PM EDT
Please click checkbox "This is correct answer" if you find it helpful!