-- The following example shows IP address encryption. The IP field type is binary.
Select * From xl_whitelist
Delete xl_whitelist
Insert into xl_whitelist (IP) values (cast ('lijian 'as binary (50 )))
Select cast (IP as char (50) from xl_whitelist
PWDENCRYPT: PWDENCRYPT encrypts the input data and returns binary encrypted content.
Pwdcompare: pwdcompare is used to check whether the plain text is equal to the encrypted binary data and there is no decryption function.
These are two undisclosed functions of sqlserver, which are mainly used for internal calls by sqlserver. The advantage is that the call is convenient. The disadvantage is that these two functions are not made public, which means they may change and are not compatible with the original functions. Therefore, there is a risk in use. (Only verified in sqlserver)
Create Table # temptable (iorder int, pswd varbinary (1024 ))
Go
Insert into # temptable values (1, pwdencrypt ('yang '))
Insert into # temptable values (2, pwdencrypt ('lianc '))
Insert into # temptable values (3, pwdencrypt ('shanc '))
Go
Select * from # temptable
Go
-- Compare whether the data is equal
Select * from # temptable
Where pwdcompare ('liany', pswd) = 1
Go
Drop table # temptable
Go