Link to home
Start Free TrialLog in
Avatar of Muralidharand
MuralidharandFlag for India

asked on

Generate Hash Key in SQL Server 2005 using SHA 512 algorithm

How to generate hash keys for a table data in SQL Server 2005 using SHA 512 algorithm?
Avatar of mayank_joshi
mayank_joshi
Flag of India image

try:-

Declare @crypt NVARCHAR(100);
set @crypt='test';

EXEC sp_OASetProperty @crypt, 'HashAlgorithm', 'sha256'
 EXEC sp_OAMethod @crypt, 'HashStringENC', @hash OUT, @s

 PRINT 'SHA256:'

 PRINT @hash

Open in new window

before running the above sql you will have to "Enable Ole automation" for SQL Server.
Follow these steps:-

start -> programs ->MS sql 2005 -> configuration tools -> surfce area configuration -> Surface area conf for features ->

Ole automation -> select the Enable check box and save
OLE Automation can also be enabled through:-

exec sp_configure 'Ole Automation Procedures', 1
go
reconfigure
go

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of mayank_joshi
mayank_joshi
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Depending on the length of the string, you can possibly use HASHBYTES.  Hashbytes supports SHA and SHA1.

http://msdn.microsoft.com/en-us/library/ms174415%28v=sql.90%29.aspx
Avatar of Muralidharand

ASKER

Your post was helpful.