The cryptographic function of an undisclosed SQL Server password _mssql

Source: Internet
Author: User
Tags mssql
If the users of the MSSQL information is interested, may find master.dbo.sysxlogins inside the user's password, but, password field if not NULL is a bunch of binary can not understand, this password is how to encrypt it?
In fact, as long as a careful look at the master.dbo.sp_addlogin will know, MSSQL SP can see the code, is really good.
Let's take a look at how it is done, note that this line of select @passwd = Pwdencrypt (@passwd), this time after the @passwd is encrypted, let us also try
DECLARE @ClearPWD varchar (255)
DECLARE @EncryptedPWD varbinary (255)
SELECT @ClearPWD = ' Test '
SELECT @EncryptedPWD = CONVERT (varbinary (255), Pwdencrypt (@ClearPWD))
SELECT @EncryptedPWD
It looks good, it's really encrypted, but how can I restore it?
  
Password encryption is one-way, with encrypted ciphertext to compare it.
Continue to look at other users related to the SP, you can find Master.dbo.sp_password inside the contents of the password comparison.
Pwdcompare (@old, password, (case when xstatus&2048 = 2048 THEN 1 ELSE 0))
Do not have to pay attention to xstatus, this is a state mask, generally we use when the direct use of 0 can be
DECLARE @ClearPWD varchar (255)
DECLARE @EncryptedPWD varbinary (255)
SELECT @ClearPWD = ' Test '
SELECT @EncryptedPWD = CONVERT (varbinary (255), Pwdencrypt (@ClearPWD))
SELECT Pwdcompare (@ClearPWD, @EncryptedPWD, 0)
SELECT pwdcompare (' Errorpassword ', @EncryptedPWD, 0)
So we can use these two functions to encrypt our passwords.
Related Article

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.