Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

One way hash functions

Tags:

sql

sql-server

How to use One way hash functions in T-SQL (Microsoft SQL) for Hash data ?

like image 236
Sudantha Avatar asked Apr 08 '26 00:04

Sudantha


2 Answers

Straight from the manual, with examples:

http://msdn.microsoft.com/en-us/library/ms174415.aspx

like image 92
Dan Grossman Avatar answered Apr 10 '26 17:04

Dan Grossman


From SQL Server 2005 and on, HASHBYTES is a built in function which can deal with MD2, MD4, MD5, SHA and SHA1. Example:

SELECT HASHBYTES('MD5', 'foo');

Note that the input should be a varchar, nvarchar or a varbinary. This blogpost highlights some of the caveeats when using HASHBYTES with columns such as char/nchar.

like image 43
alexn Avatar answered Apr 10 '26 16:04

alexn