Home > Database > Mysql Tutorial > How Does SQL Server's PBKDF2 Function Hash Passwords?

How Does SQL Server's PBKDF2 Function Hash Passwords?

Patricia Arquette
Release: 2024-12-20 03:04:09
Original
879 people have browsed it

How Does SQL Server's PBKDF2 Function Hash Passwords?

SQL Server 2012 introduced the PBKDF2 function, which implements the PBKDF2 algorithm using HMAC-SHA512. The PBKDF2 function takes four parameters:

  • password: The password to be hashed.
  • salt: A random salt value.
  • iterations: The number of iterations to perform.
  • outputBytes: The number of output bytes to generate.

The PBKDF2 function returns a binary value that contains the hashed password. The following SQL statement shows how to use the PBKDF2 function to hash a password:

DECLARE @password VARBINARY(128) = 0x1234567890ABCDEF;
DECLARE @salt VARBINARY(16) = 0xABCDEF0123456789;
DECLARE @iterations INT = 10000;
DECLARE @outputBytes INT = 64;

DECLARE @hashedPassword VARBINARY(64);

SELECT @hashedPassword = PBKDF2(@password, @salt, @iterations, @outputBytes);

-- The value of @hashedPassword will be a binary value that contains the hashed password.
Copy after login

PBKDF2 is a secure password hashing algorithm that is resistant to brute-force attacks. It is recommended to use PBKDF2 to hash passwords in SQL Server 2012 and later.

The above is the detailed content of How Does SQL Server's PBKDF2 Function Hash Passwords?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template