HMACString
Computes the MD5, RIPEMD160, SHA1, SHA256, SHA384, or SHA512 Hash-based Message Authentication (HMAC) of a string input in SQL Server
- Free Function
- SQL Server Compatibility: 2008, 2012, 2014, 2016, 2017
SELECT SQLHTTP.net.HMACString ( @Algorithm, @StringToHash, @HashKey )
Name | Type | Description |
---|---|---|
@Algorithm | varchar(20) | One of the following Algorithms: MD5, RIPEMD160, SHA1, SHA256, SHA384, or SHA512 |
@StringToHash | varchar(MAX) | string data to hash |
@HashKey | varchar(MAX) | The key to use in the hash algorithm |
varbinary(MAX)
We provide two distinct functions: HMACBinary and HMACString
1 2 3 4 5 6 7 8 9 10 11 12 13 |
DECLARE @Algorithm varchar(20) DECLARE @StringToHash varchar(MAX) DECLARE @HashKey varchar(MAX) SET @Algorithm = 'MD5' SET @StringToHash = 'The quick brown fox jumps over the lazy dog' SET @HashKey = 'Secret Key or passphrase' SELECT SQLHTTP.net.HMACString(@Algorithm, @StringToHash, @HashKey) |
1 2 3 4 |
-------------------------------------------------- 0x0215902C5DF4F804CE5FEB4371F90541 |