|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Thursday, December 06, 2012 1:17 PM
Points: 24,
Visits: 76
|
|
| Comments posted to this topic are about the item MD5
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Friday, March 19, 2010 9:51 AM
Points: 1,
Visits: 11
|
|
So how do you decrypt it?
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Thursday, December 06, 2012 1:17 PM
Points: 24,
Visits: 76
|
|
MD5 is a 'one way' algorithm. you can't decrypt it. is very usefull to encrypt passwords, or data that you don't need to read directly. for instance, if i store a md5 string of my password, the system have to compare two md5 strings (password_stored vs MD5(password_wrote)) to verify if my password is correct and letme log in.
greets...
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Monday, May 06, 2013 10:40 AM
Points: 19,
Visits: 143
|
|
You must not use CAST(... AS NVARCHAR(32)), that would remove the 2 last characters
-- with SqlServer 2005 DECLARE @md5 VARCHAR(32) DECLARE @string varchar(10) SET @string = 'Davolio' SELECT HashBytes('MD5',@string ), master.dbo.fn_varbintohexstr(HashBytes('MD5',@string )), SUBSTRING(master.dbo.fn_varbintohexstr(HashBytes('MD5',@string )),3,32 ), SUBSTRING(CAST(master.dbo.fn_varbintohexstr(HashBytes('MD5',@string )) AS NVARCHAR(32)),3,32 )
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Thursday, December 06, 2012 1:17 PM
Points: 24,
Visits: 76
|
|
You are totally right... typin' mistake...
the 'CAST' is to a NVARCHAR(MAX)
I tried a lot whitout that CAST and it returned another 'md5' string... i figure that the problem is in the asigment '@md5 = ...'
the sql corrected would be...
CREATE FUNCTION [dbo].[fn_MD5] ( @string AS VARCHAR(MAX), @chars AS INT ) RETURNS NVARCHAR(32) AS BEGIN -- Declare the return variable here DECLARE @md5 NVARCHAR(32)
SELECT @md5 = SUBSTRING(CAST(master.dbo.fn_varbintohexstr(HashBytes('MD5',@string )) AS NVARCHAR(MAX)),3,@chars )
-- Return the result of the function RETURN @md5 END
|
|
|
|