Tuesday, 3 March 2015

How to Encrypt password in SQL Server?

Security is always a concern for every database developer. How to secure valuable information is one of the major and important aspect.

The first approach toward security to have a strong username & password and the next step is to have password in encrypted form.

So SQL Server provided a function by using that particular simple function we can encrypt a password from plain text to hash.

The valuable function are PWDENCRYPT and HASHBYTES.  By the name it is clear that it will crease the password.

The syntax for PWDENCRYPT is:

  PWDENCRYPT(N’String to encrypt’)

HASHBYTES function which is available for secure your password using various Hash algorithms like MD2 , MD4 , MD5 , SHA ,SHA1 , SHA2_256 , SHA2_512.

The PWDENCRYPT  can be use but  HASHBYTES function provides you various options to make your content robust secure.

The Syntax is very easy as shown below
HASHBYTES (ALGORITHM, ‘Text to secure’)


Here, SHA2_256, SHA2_512 available with 2012 version and above.


No comments:

Post a Comment