一、首先要把密碼字段改成varbinary 類型。
CREATE TABLE [dbo].[UserInfo]([id] [int] IDENTITY(1,1) NOT NULL,[name] [varchar](50) NULL,[passWord] [varbinary](128) NULL) ON [PRIMARY]
二、插入數據的時候需要使用PWDENCRYPT() 函數
insert into dbo.UserInfo (name,password) values ('admin',PWDENCRYPT('123456'))
三、登陸判斷時需要使用PWDCOMPARE() 函數 做一下比較
select * from dbo.UserInfo where name='admin' and PWDCOMPARE('123456',password)=1
新聞熱點
疑難解答