Home Dashboard Directory Help
Search

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


Status: 

Active


1
0
Sign in
to vote
Type: Bug
ID: 788570
Opened: 5/24/2013 7:43:30 AM
Access Restriction: Public
1
Workaround(s)
view
0
User(s) can reproduce this bug

Description

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.
Details
Sign in to post a comment.
Posted by Microsoft on 5/30/2013 at 11:24 AM
Hello,
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
Sign in to post a workaround.
Posted by DB007 on 5/24/2013 at 8:34 AM
Workaround - is to replace varbinary with varbinary(max).