Im trying to do a MD5 check for a file uploaded to a varbinary field in MSSQL 2005.
I uploaded the file and using
SELECT DATALENGTH(thefile) FROM table
I get the same number of bytes that the file has.
But using MD5 calculator (from bullzip) i get this MD5:
20cb960d7b191d0c8bc390d135f63624
and using SQL I get this MD5:
44c29edb103a2872f519ad0c9a0fdaaa
Why they are different if the field has the same lenght and so i assume the same bytes?
My SQL Code to do that was:
DECLARE @HashThis varbinary;
DECLARE @md5text varchar(250);
SELECT @HashThis = thefile FROM CFile WHERE id=1;
SET @md5text = SUBSTRING(sys.fn_sqlvarbasetostr(HASHBYTES('MD5',@HashThis)),3,32)
PRINT @md5text;
Maybe the data type conversion?
Any tip will be helpful.
Thanks a lot :)