Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Encrypt / Decrypt password field

Status
Not open for further replies.

ANGELFIRE

Technical User
Sep 22, 2001
8
0
0
US
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?
 
Hi There

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'


Hope this helps
Good Luck
Bernadette


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top