SQL field encryption function

Source: Internet
Author: User

-- 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.