System.Security.Cryptography.MD5CryptoServiceProvider

Discussion in 'ASP .Net Security' started by Mike, Oct 16, 2003.

  1. Mike

    Mike Guest

    I'm wonder if anyone has tested the
    System.Security.Cryptography.MD5CryptoServiceProvider
    against the RFC 1321 Test suite?

    For example, here is the list of string to hash for md5:
    MD5 ("") = d41d8cd98f00b204e9800998ecf8427e
    MD5 ("a") = 0cc175b9c0f1b6a831c399e269772661
    MD5 ("abc") = 900150983cd24fb0d6963f7d28e17f72

    I haven't been able to these result? Has anyone gotten it
    to work? If yes, what did you have to do?
    Mike, Oct 16, 2003
    #1
    1. Advertising

  2. They all work.

    using System;
    using System.Security.Cryptography;
    using System.Text;

    public class MD5Test {
    public static void Main (string[] args)
    {
    MD5 hash = MD5.Create ();
    byte[] data = new byte [0];
    byte[] empty = hash.ComputeHash (data);
    Console.WriteLine (BitConverter.ToString (empty));

    data = Encoding.ASCII.GetBytes ("a");
    byte[] a = hash.ComputeHash (data);
    Console.WriteLine (BitConverter.ToString (a));

    data = Encoding.ASCII.GetBytes ("abc");
    byte[] abc = hash.ComputeHash (data);
    Console.WriteLine (BitConverter.ToString (abc));
    }
    }

    One common error in using hash with .NET is hashing a unicode string.

    Sebastien

    "Mike" <> wrote in message
    news:093b01c39389$64b8c860$...
    > I'm wonder if anyone has tested the
    > System.Security.Cryptography.MD5CryptoServiceProvider
    > against the RFC 1321 Test suite?
    >
    > For example, here is the list of string to hash for md5:
    > MD5 ("") = d41d8cd98f00b204e9800998ecf8427e
    > MD5 ("a") = 0cc175b9c0f1b6a831c399e269772661
    > MD5 ("abc") = 900150983cd24fb0d6963f7d28e17f72
    >
    > I haven't been able to these result? Has anyone gotten it
    > to work? If yes, what did you have to do?
    Sébastien Pouliot, Oct 16, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mauricio Correa L.

    Generating hashes (System.security.cryptography)

    Mauricio Correa L., Jun 18, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    399
    Raterus
    Jun 18, 2004
  2. Dei401
    Replies:
    0
    Views:
    781
    Dei401
    Feb 2, 2005
  3. muthu
    Replies:
    1
    Views:
    523
    Winista
    Jul 10, 2006
  4. =?Utf-8?B?ZGF2aWQ=?=
    Replies:
    1
    Views:
    362
    =?Utf-8?B?TWFuaXNoIEJhZm5h?=
    Dec 21, 2006
  5. Amelyan
    Replies:
    0
    Views:
    581
    Amelyan
    Aug 12, 2007
Loading...

Share This Page