Last post Jul 04, 2012 10:05 PM by Decker Dong - MSFT
Jul 03, 2012 11:09 AM|larshittu|LINK
Have a Table that has Column with a varbinary Datatype. after i hash a value to it with SHA1, Am having problem in retrieve the original value back.
DECLARE @RealPin, @HashPin
Select @RealPin = Cast(((@maxRandValue + 1) - @minRandValue) * Rand() + @minRandValue As Numeric)
SELECT @RealPin = CONVERT(nvarchar, @RealPin);
SELECT @HashPin = HashBytes('SHA1', @RealPin);
Am Generating Random Number.
Then i insert the @HashPIN to the Column with the varbinary Datatype.
What do i do to get the @RealPin Back, I mean what is the SELECT Query Method i will use..
Please i need help asap..
Jul 03, 2012 11:19 AM|AWAlger|LINK
Hashbytes can not be decrypted they are one direction. The only way to know the value is to hash another value and compare the two to see if they match.
Coding is like life, learn from the past and work towards the future, trying to redo past code, ends in lost time and nothing new accomplished.
Jul 03, 2012 11:29 AM|larshittu|LINK
Thanks for the Quick Response.
Please can give me sample of hash method that can still be decrypted either by C# Code behind for asp.net web app or using store procedure because i actully use store procedure to do the Random Number Generating..
Please help Thanks.
Jul 03, 2012 11:49 AM|AWAlger|LINK
YOu are going to have to encrypt the database to do that on that side. Word of caution when following this link. Backup the cert you create from these steps or recovering the database will be impossible.
on the C# side
Jul 04, 2012 10:05 PM|Decker Dong - MSFT|LINK
Please can give me sample of hash method that can still be decrypted
As the man said earlier，HashBytes cannot be decrypted……What you can do is to just do comparation by accpeting the two values： One value comes from your Textbox of your aspx page, while the another one comes from database，both of them should be encypted advance
and the compare whether the value equals or not……