简单密码加密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)

解决方案 »

  1.   

    --SQL SERVER 本身也提代加密密码的函数:
    --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
      

  2.   

    CREATE TABLE Users ( 
    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')))
      

  3.   

    pwdencrypt ,pwdcompare是Sql server 的标准函数吗,具体如何使用呢
      

  4.   

    直接使用就是了
    pwdencrypt(pwdencrypt('abcd'))=='abcd'
      

  5.   

    pwdencrypt ,pwdcompare等函数从哪可得相关信息哪,sql server帮助中没有