Re: System.Security.Cryptography.MD5CryptoServiceProvider

From: Sébastien Pouliot (spouliot_at_videotron.ca)
Date: 10/16/03

  • Next message: Rajesh.V: "Re: Problem with Forms Authentication cookies"
    Date: Wed, 15 Oct 2003 22:28:12 -0400
    
    

    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" <no_spam_plz@mypse.com> wrote in message
    news:093b01c39389$64b8c860$a301280a@phx.gbl...
    > 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?


  • Next message: Rajesh.V: "Re: Problem with Forms Authentication cookies"

    Relevant Pages

    • Re: How to write a diff in VB6 for comparing two xml files?
      ... No, the best you could do is to read both into string and use StrCompbut it's inefficient and, but using the hash ... Private Declare Function CryptAcquireContext Lib "AdvAPI32.dll" Alias _ ... Dim HashAAs Byte, HashLenA As Long ...
      (microsoft.public.vb.general.discussion)
    • Re: something like switch in c
      ... >> straightforward string comparisions. ... > inner table size and/or add symbols to expand the hash. ... It all depends on the empirical pattern of the actual keys. ... The value of the random number generator is UNCHANGED on ...
      (comp.programming)
    • Re: How to make PKCS#7 signature using CryptoAPI?
      ... Those MSDN samples hash a string PLUS the null byte (so that it ... I tried your sample and had no problem verifying with openssl (after I added ... functions (including CryptSignMessage). ...
      (microsoft.public.platformsdk.security)
    • Re: How to make PKCS#7 signature using CryptoAPI?
      ... "Mitch Gallant" wrote: ... Those MSDN samples hash a string PLUS the null byte (so that it ... functions (including CryptSignMessage). ...
      (microsoft.public.platformsdk.security)
    • Re: Base36
      ... static string tokens = ... But - I don't think you want all those silly characters in the product key. ... I should be able to recalc the hash at the client ... > conversion to long so I can pass each long to the BaseXX converter to get ...
      (microsoft.public.dotnet.languages.csharp)