MD5 implementation

From: Casper Hornstrup (msdn_at_csite.com)
Date: 02/04/04


Date: Wed, 4 Feb 2004 11:04:53 +0100

I need to use MD5 to generate a hash of a string. It needs to be
compatible with the MD5 implementation in PHP.

public string ComputeMD5(string plain)
{
 MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
 byte[] bMD5Hash = Encoding.ASCII.GetBytes(plain);
 return Encoding.ASCII.GetString(md5.ComputeHash(bMD5Hash));
 //return Convert.ToBase64String(md5.ComputeHash(bMD5Hash));
}

With PHP I get:
md5('test1test1test1test1test1test1') = '0b2fc97f2a37500552d805c4727295a8'

In .NET I get:
ComputeMD5('test1test1test1test1test1test1') = ' /I*7PRXDrr('
ComputeMD5('test1test1test1test1test1test1') = 'Cy/Jfyo3UAVS2AXEcnKVqA=='
(base64)

Am I doing it wrong or are the PHP and .NET implementations not compatible?

Thanks in advance,
Casper Hornstrup



Relevant Pages

  • Re: MD5 implementation
    ... "Casper Hornstrup" wrote in message ... > compatible with the MD5 implementation in PHP. ... > public string ComputeMD5 ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: [PHP] PHP5 and the DOM model
    ... Seems that PHP gets more and more object oriented, ... readonly public string ... have you looked at SimpleXMLElement / SimpleXMLIterator ?? ...
    (php.general)

Loading