HashBinary
Computes the MD5, RIPEMD160, SHA1, SHA256, SHA384, or SHA512 hash of a binary input in SQL Server without an 8000 bytes limitation
- Free Function
- SQL Server Compatibility: 2008, 2012, 2014, 2016, 2017
SELECT SQLHTTP.net.HashBinary ( @Algorithm, @BinaryToHash )
Name | Type | Description |
---|---|---|
@Algorithm | varchar(20) |
One of the following Algorithm: MD5, RIPEMD160, SHA1, SHA256, SHA384, or SHA512 |
@BinaryToHash | varbinary(MAX) | Binary data to hash |
varbinary(MAX)
This function is similar to the Microsoft’s HashBytes SQL Server function, but with slightly different algorithms and without the 8000 bytes limitation. We provide three distinct functions: HashBinary, HashString, and HashUnicode
1 2 3 4 5 6 7 8 9 10 |
DECLARE @Algorithm varchar(20) DECLARE @BinaryToHash varbinary(MAX) SET @Algorithm = 'SHA1' SET @BinaryToHash = 0x540068006500200071007500690063006B002000620072006F0077006E00200066006F00780020006A0075006D007000730020006F00760065007200200074006800650020006C0061007A007900200064006F006700 SELECT SQLHTTP.net.HashBinary(@Algorithm, @BinaryToHash) |
1 2 3 4 |
-------------------------------------------------- 0xBD136CB58899C93173C33A90DDE95EAD0D0CF6DF |