If you are interested in MSSQL user information, you may find the Master. DBO. sysxlogins stores user passwords. However, if the password field is not null, It is a bunch of binary files that cannot be understood. How is this password encrypted?
In fact, you only need to take a closer look at Master. DBO. sp_addlog
If you are interested in MSSQL user information, you may find the Master. DBO. sysxlogins stores user passwords. However, if the password field is not null, It is a bunch of binary files that cannot be understood. How is this password encrypted?
In fact, you only need to take a closer look at Master. DBO. sp_addlogin. You can see all the MSSQL Sp.CodeYes.
Let's take a look at how it works. Pay attention to this line of select @ passwd = pwdencrypt (@ passwd). After this, @ passwd will be encrypted. Let's also try it.
Declare @ Clearpwd Varchar ( 255 )
Declare @ Encryptedpwd Varbinary ( 255 )
Select @ Clearpwd = ' Test '
Select @ Encryptedpwd = Convert ( Varbinary ( 255 ), Pwdencrypt ( @ Clearpwd ))
Select @ Encryptedpwd
It looks good. It is indeed encrypted, but how can I restore it?
Oh, that's no problem. Password Encryption is one-way. You can use encrypted passwords to compare them.
Continue to look at the SP related to other users. You can find that the master. DBO. sp_password contains the password comparison content.
Pwdcompare (@ old, password, (case when xstatus & 2048 = 2048 then 1 else 0 end ))
Ignore xstatus. This is a status mask. Generally, we can use 0 directly.
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 )
In this way, we can use these two functions to encrypt our own passwords. How is it good? The above content is an introduction to the undisclosed ms SQL Server encryption functions. I hope you will get some benefits.
The above content is a description of the undisclosed ms SQL Server encryption function, hoping to help you in this regard.
This articleArticleSource: Institute of Development http://edu.codepub.com Source: http://edu.codepub.com/2010/0729/24644.php