PDA

View Full Version : how to encrypt password ??


meidianakusuma
01-27-2009, 05:55 AM
i'm using asp.net3.5, and using sql server 2000 to store my database,
i don't know how to encrypt my text (in the textbox that is password) and send the encrypted text to my database.

i ever used this but it have error every where :(:(:(:(:(:(
Public Function ComputeHashValue(ByVal data As Byte) As Byte
Dim hashAlg As SHA1 = SHA1.Create()
Dim hashvalue As Byte()
hashvalue = hashAlg.ComputeHash()
Return hashvalue
End Function

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim test As Byte
test = ComputeHashValue(Encoding.ASCII.GetHashCode(TextBox1.Text))
End Sub

i already search in the internet but it didn't work

vinyl-junkie
01-27-2009, 01:01 PM
The database you're using and .NET framework version shouldn't make any difference. Any of the methods to encrypt passwords, regardless of how old they are, should still work for you. Did you try this one (http://aspnet.4guysfromrolla.com/articles/103002-1.2.aspx)?

demtron
01-28-2009, 03:36 AM
Check out the post at http://www.devcity.net/Articles/47/1/encrypt_querystring.aspx. I have used this code for a number of years and it's excellent.

saji
02-21-2009, 12:29 PM
Try this function to encrypt the username or password
//This function is used to encrypt the username and password
public static string Encrypt(string clearText, string Password)
{
// First we need to turn the input string into a byte array.

byte[] clearBytes = System.Text.Encoding.Unicode.GetBytes(clearText);
PasswordDeriveBytes pdb = new PasswordDeriveBytes(Password,
new byte[] { 0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76 });
byte[] encryptedData = Encrypt(clearBytes, pdb.GetBytes(32), pdb.GetBytes(16));
return Convert.ToBase64String(encryptedData);
}