Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
HI,
How can we hash the passwords in an already existing database? The passwords in the database are in clear text, which is a security issue. I don't want to use the in-built SQL Server hash functions, but create my own application for hashing the passwords. I was thinking of creating another column of datatype varbinary(16) -MD5 hash- and storing the hashed values there and deleting the cleartext password column.
ALso, I read that salting is very important. What do you guys think? Any ideas are most welcome.
Posted

Storing passwords in plain text is really bad idea. Don't ever do that.

You can convert the password into hash in code level and store in the database as a character string. Are you working with C# or something else?
 
Share this answer
 
v2
Comments
kittydas 20-Sep-11 3:14am    
C++
CodingLover 20-Sep-11 3:58am    
I used the following in most of the cases.

http://www.cplusplus.com/reference/std/locale/collate/hash/
1. Write a quick console app to hash the passwords outside of SQL.
2. Yes, salt.
 
Share this answer
 
You will have to add another column pwd_salt in the database
and generate the pwd_salt randomly

concate pwd + pwd_salt to a string
convert string to bytes
and use computehash function from System.Security.Cryptography.SHA1Managed of .net class to compute hash.
 
Share this answer
 
 
Share this answer
 
You can use SQL internal encryption functions
EncryptByPassPhrase[^]
decryptbypassphrase[^]
for encryption of perticular column.

OR

Play your own logic of text encryption.


Simple encrypting and decrypting data in C#[^]

http://www.geekinterview.com/talk/1527-encrypt-password-in-c-net.html[^]
 
Share this answer
 
Comments
Chris Maunder 20-Sep-11 0:27am    
Encrypting passwords is a bad idea. The poster was asking about hashing. Two very different beasts.
CodingLover 20-Sep-11 0:31am    
I agreed with Chris.
kittydas 20-Sep-11 3:13am    
Agreed with Chris too. Hash functions are one-way functions. Encryption is two-way.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900