.NET's CryptoStream vs Java's .update()

From: Brandon Bloom (BrandonBloom_at_discussions.microsoft.com)
Date: 11/19/04


Date: Fri, 19 Nov 2004 12:35:01 -0800

I am porting a Java application to .NET and came across a problem working
with .NET’s MD5CryptoServiceProvider producing a different result from Java’s
MessageDigest. I was hoping someone could help me as this as the only thread
I could find that tackled the subject directly:

http://groups.google.com/groups?hl=en&lr=&c2coff=1&safe=off&threadm=OjHc2kP6DHA.3360%40tk2msftngp13.phx.gbl&rnum=5&prev=/groups%3Fq%3Dmd5%2B.hash%2Bcryptostream%26hl%3Den%26lr%3D%26c2coff%3D1%26safe%3Doff%26selm%3DOjHc2kP6DHA.3360%2540tk2msftngp13.phx.gbl%26rnum%3D5

I have a Java application that calls MessageDigest.getInstance("MD5") and
then calls .update() three times on the MessageDigest instance returned.
Afterwards, .digest() is called. In my C# application I create a
MD5CryptoServiceProvider and CryptoStream as you suggested and call .Write()
three times with the same information. After carefully checking all three
calls and the data passed to each numerous times (with the understanding that
Java uses signed bytes where as C# doesn’t), I have found no differences, but
the C# version returns a different Hash from the .Hash property. Why? How can
I correct this?

Any help would be greatly appreciated.

Thank you for your time,
Brandon Bloom



Relevant Pages

  • Re: convert JAVA hash to Delphi
    ... I'm not familiar with JAVA, but need to convert write something in Delphi ... I know that MessageDigest and the call to Digest are defined within JAVA ... FileInputStream myFileStream = new FileInputStream; ... DigestInputStream myDigestStream = new DigestInputStream( ...
    (alt.comp.lang.borland-delphi)
  • convert JAVA hash to Delphi
    ... I'm not familiar with JAVA, but need to convert write something in Delphi to ... I know that MessageDigest and the call to Digest are defined within JAVA ... FileInputStream myFileStream = new FileInputStream; ... DigestInputStream myDigestStream = new DigestInputStream( ...
    (alt.comp.lang.borland-delphi)