简单密码加密declare @logintable table(username varchar(20),passwd varbinary(256))
insert @logintable(username,passwd) values('yourname',pwdencrypt('123456'))declare @pwd varbinary(256)select @pwd=passwd from @logintable where username='yourname'
--比较:
if pwdcompare('123456',@pwd)=1
print 'true'
else
print 'false'select * from @logintableselect pwdcompare('12456',@pwd)
insert @logintable(username,passwd) values('yourname',pwdencrypt('123456'))declare @pwd varbinary(256)select @pwd=passwd from @logintable where username='yourname'
--比较:
if pwdcompare('123456',@pwd)=1
print 'true'
else
print 'false'select * from @logintableselect pwdcompare('12456',@pwd)
--pwdencrypt ,pwdcompare
--加密:
declare @logintable table(username varchar(20),passwd varbinary(256))
insert @logintable(username,passwd) values('yourname',pwdencrypt('123456'))declare @pwd varbinary(256)select @pwd=passwd from @logintable where username='yourname'
--比较:
if pwdcompare('12356',@pwd)=1
print 'true'
else
print 'false'select * from @logintable
UserID Varchar(10),
UserPW Varchar (20))INSERT INTO USERS values('TestUser1',ENCRYPT('TestPW1'))
INSERT INTO USERS values('TestUser2',ENCRYPT('TestPW2'))
INSERT INTO USERS values('TestUser3',ENCRYPT('TestPW3'))
INSERT INTO USERS values('TestUser4',ENCRYPT('TestPW4'))SELECT * from Users where UserID = 'TestUser2'
and UserPW = ENCRYPT('TestPW2')--不区分大小写
INSERT INTO USERS values('TestUser1',ENCRYPT(UPPER('TestPW1')))
pwdencrypt(pwdencrypt('abcd'))=='abcd'