HASHBYTES - Incorrect Data Conversion when using SHA2_256 / SHA2_512 - by DB007

Status : 

  By Design<br /><br />
		The product team believes this item works according to its intended design.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 788570 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 5/24/2013 7:43:30 AM
Access Restriction Public


Quick Summary:
Conversion of a HASHBYTE (SHA2_256/SHA2_512) does not correctly convert to a varchar datatype -> varbinary datatype.

The value returned should match the input supplied in this case.
Sign in to post a comment.
Posted by Microsoft on 5/30/2013 at 11:24 AM
The result is expected. If you don't specify a length for varbinary type in CONVERT function then the default length is 30 not max. Use explicit length in the variable types otherwise you will get wrong results like this.

Umachandar, SQL Programmability Team