I have a problem regarding the encryption and decryption of password field in SQL? How can I encrypt / decrypt the password? Could someone give me a sample code for encryption and decryption?
In SQL Server logins are encyrpted by default. However you can create a login without encrypting the password, but it is not recommended.
--------------------------------------------------------
Example: Creating a login for Mary with password
- rose without an encrypted password
------------------------------------------------------
EXEC sp_addlogin 'Mary', 'rose',
@encryptopt = 'skip_encryption'
--------------------------------------------------------
To read the password in Master..syslogins:
--------------------------------------------------------
SELECT password FROM syslogins where name = 'Mary'
--------------------------------------------------------
To create a password with encryption (default)
--------------------------------------------------------
EXEC sp_addlogin 'Mary', 'rose
--------------------------------------------------------
Read encrypted password for Mary
--------------------------------------------------------
SELECT CONVERT(VARBINARY(32), password)
FROM syslogins
WHERE name = 'Mary'
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.