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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 PWDENCRYPT & PWDCOMPARE

Author  Topic 

fisherman_jake
Slave to the Almighty Yak

159 Posts

Posted - 2002-09-03 : 20:25:16
For the old timers..

Sorry, it's been a while since I've written in, but here's one for you.

1. How do I go about storing the results from PWDENCRYPT?
2. Will using PWDCOMPARE on the stored data work?

Thanks in advance!!



==================================================
Do not argue with IDIOTS. They will take you down to their level and BEAT you with experience.
Master Fisherman

ashok
Yak Posting Veteran

57 Posts

Posted - 2002-09-04 : 03:03:55
PWDENCRYPT(passwd) (passwd- password to encrypt)
PWDCOMPARE(passwd,enc,encold)
passwd- password to compare
enc - encrypted password
encold- 1 or 0 indicating wheter old-style encryption was used to encrypt
pwd (default 0)

SELECT PWDENCRYPT('password') , PWDCOMPARE('password', PWDENCRYPT('password'))

from what i recall you can store the encrypted password in a binary(48) field...

i would be careful using pwdencrypt() though - i dont think its compatible across sql server versions...



Go to Top of Page

fisherman_jake
Slave to the Almighty Yak

159 Posts

Posted - 2002-09-04 : 03:10:08
Thanks, I just had a whack at it, trial and error..

 
--<TSQL START>--
create table #PWDTEst (
login varchar(20),
UserPassword nvarchar(256))
insert #PWDTEst values ( 'lapidi', PWDENCRYPT('SQLserverPassword1'))
select login, password = 'SQLserverPassword1', PWDCOMPARE('SQLserverPassword1', UserPassword, 0) from #PWDTEst
select login, password = 'BadPassword', PWDCOMPARE('BadPassword', UserPassword, 0) from #PWDTEst
--<TSQL END>--


Works like a dream.. CHeers!!

==================================================
Do not argue with IDIOTS. They will take you down to their level and BEAT you with experience.
Master Fisherman
Go to Top of Page
   

- Advertisement -