tags:

views:

268

answers:

3

how can i encrypt password field in asp.net mvc to be store in encrypted form

+1  A: 

Typical workflow would involve generating a salt value and using that to hash the password and then storing them both in the row. This is documented in detail in many places and is easily searched.

If you truly just want a way to quickly hash or encrypt without salt take a look at FormsAuthentication.HashPasswordForStoringInConfigFile

Sky Sanders
+2  A: 

If you are concerned about sending plain text over the wire, use https. Then whether you use https or not use a one way hashing algorithm such as Sha256 to "encrypt" the password and store that in your database (or whatever persistent storage you are using). When a user logs in, use the same algorithm, to convert the text they entered into the hashed text and compare the hashed text with the hashed text in your database.

s1mm0t
+1  A: 

Here is a very good code example for encryption and decryption any string. where key is the value you want to encrypt or decrypt

public static string Encrypt(string key) { string encryptedstring; byte[] data;

        data = System.Text.ASCIIEncoding.ASCII.GetBytes(key);
        encryptedstring = Convert.ToBase64String(data);

        return encryptedstring;
    }

public static string Decrypt(string key) { byte[] data; string decryptedstring;

        data = Convert.FromBase64String(key);
        decryptedstring = System.Text.ASCIIEncoding.ASCII.GetString(data);
        return decryptedstring;
    }
Fraz Sundal