﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Article Discussions / Article Discussions by Author / Discuss content posted by Caesar-719283  / MD5 / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Tue, 18 Jun 2013 22:22:07 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: MD5</title><link>http://www.sqlservercentral.com/Forums/Topic797101-1666-1.aspx</link><description>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)ASBEGIN	-- 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 @md5END</description><pubDate>Tue, 03 Nov 2009 05:19:50 GMT</pubDate><dc:creator>Caesar2</dc:creator></item><item><title>RE: MD5</title><link>http://www.sqlservercentral.com/Forums/Topic797101-1666-1.aspx</link><description>You must not use CAST(...  AS NVARCHAR(32)), that would remove the 2 last characters-- with SqlServer 2005DECLARE @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 )</description><pubDate>Tue, 03 Nov 2009 04:09:56 GMT</pubDate><dc:creator>phamminh</dc:creator></item><item><title>RE: MD5</title><link>http://www.sqlservercentral.com/Forums/Topic797101-1666-1.aspx</link><description>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...</description><pubDate>Wed, 14 Oct 2009 10:11:40 GMT</pubDate><dc:creator>Caesar2</dc:creator></item><item><title>RE: MD5</title><link>http://www.sqlservercentral.com/Forums/Topic797101-1666-1.aspx</link><description>So how do you decrypt it?</description><pubDate>Wed, 14 Oct 2009 10:00:24 GMT</pubDate><dc:creator>jbinnig</dc:creator></item><item><title>MD5</title><link>http://www.sqlservercentral.com/Forums/Topic797101-1666-1.aspx</link><description>Comments posted to this topic are about the item [B]&lt;A HREF="/scripts/md5+function+password+encrypt+sql+2005/68316/"&gt;MD5&lt;/A&gt;[/B]</description><pubDate>Fri, 02 Oct 2009 11:13:06 GMT</pubDate><dc:creator>Caesar2</dc:creator></item></channel></rss>