Using HASHBYTES

The HASHBYTES built-in function is used to hash the string of characters using one of the seven supported hashing algorithms. The function accepts the following two input arguments:

  • algorithm: This is a hashing algorithm for hashing the input. The possible values are MD2, MD4, MD5, SHA, SHA1, SHA2_256, and SHA2_512, but only the last two are recommended in SQL Server 2017.
  • input: This is an input variable, column, or expression that needs to be hashed. The data types that are allowed are varchar, nvarchar, and varbinary.

The return type of the function is varbinary (8000). This function has been available in SQL Server since 2005, but it is enhanced in SQL Server 2016. The most important enhancement is removing the limit ...

Get SQL Server 2017 Developer's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.