A R

A R

  • NA
  • 2
  • 0

C# Conversion from Java (Message Digest to Md5CryptoServiceProvider)

Oct 1 2007 12:08 PM

I currently have a java program that is creating a MD5 message digest using the following...

MessageDigest dig = MessageDigest.getInstance("MD5");
dig.update(secret);
dig.update(key, offset, len);
return dig.digest();

The problem I am having is that java is using a signed byte array for key and unsigned for secret. How is it possible to change this is C#?

I have the following code in C#:

MD5CryptoServiceProvider md = new MD5CryptoService Provider();
CryptoStream cs = new CryptoStream(Stream.Null, md, CryptoStreamMode.write);
cs.Write(secret, 0, 0);
cs.Write(key, offset, len);
cs.Close();

However secret is a byte[] and key is an sbyte[] to make them the same as in java. I ahave no idea? Any help would be appreciated.


Answers (2)