Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
amex45
Starting Member
16 Posts |
Posted - 2001-11-27 : 11:23:51
|
| Is there any way to store the passwords in the encrypted format in sql server? I don’t want to convert the data type in to varbinary and then to char? |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2001-11-27 : 11:29:05
|
| You can use PWDENCRYPT() to encrypt a password:INSERT INTO users(UserID, Password) VALUES ('robvolk', PWDENCRYPT('mypassword'))You can check it with PWDCOMPARE():SELECT PWDCOMPARE('let me in', Password) FROM Users WHERE UserID='robvolk' --returns 0, no matchSELECT PWDCOMPARE('mypassword', Password) FROM Users WHERE UserID='robvolk' --returns 1, matchYou'll have to store the passwords in a varbinary column though. You cannot decrypt passwords, ever, nor would you want to. You can only use PWDCOMPARE to compare a plaintext password to an encrypted value.BTW, since this is an undocumented feature, be very careful about relying on it too much. The encryption algorithm was changed between 6.5 and 7.0, and it may happen with the next release of SQL Server. |
 |
|
|
amex45
Starting Member
16 Posts |
Posted - 2001-11-27 : 13:58:04
|
| Thanks Rob! |
 |
|
|
|
|
|