Sql下表和字段的加密和解密

解决方案 »

  1.   

    pwdencrypt() pwdcompare() 函数
    declare @table1 (aaa varchar(100))
    declare @tmp1 varchar(100)insert @table1(aaa) vlaues (pwdencrypt('12345')select @tmp1=aaa from @table1if pwdcompare('12345',@tmp1) =1
        print 'true'
    else
        print 'false'
      

  2.   

    select pwdencrypt(8)
    select pwdcompare(8,pwdencrypt(8))
    select pwdcompare(9,pwdencrypt(8))
      

  3.   

    set nocount on 
    declare @tb table (a varbinary(8000))
    insert into @tb select pwdencrypt(8)
    union all select pwdencrypt('test')
    union all select pwdencrypt(8.8)
    -- select * from @tb
    declare @test varbinary(8000)
    declare c_pwd cursor for select * from @tb
    open c_pwd
    fetch next from c_pwd into @test
    while @@fetch_status=0
    begin
    if pwdcompare(8,@test)=1
    begin print '8 :' print @test end
    else if  pwdcompare('test',@test)=1
    begin print 'test :' print @test end
    else  if pwdcompare(8.8,@test)=1
    begin print '8.8 :' print @test end
    fetch next from c_pwd into @test
    end
    close c_pwd
    deallocate c_pwd
    set nocount off
    pwdencrypt()
    pwdcompare()
    是微软未公布的两个数据库函数
    据说是当初用漏洞补丁早就发布了,现在没有问题