MD5 for String problem whit Java and C#

Hi

This is from existing program written in C#

publicstatic string Crypt(string text)

{

ASCIIEncoding a =new ASCIIEncoding();

System.Security.Cryptography.MD5 md5 =new MD5CryptoServiceProvider();

byte[] h = md5.ComputeHash(a.GetBytes(text));

string mac ="";

for(int i=0; i<h.Length; i++)

{

mac += h[i].ToString("x2");

}

return mac;

}

Now I should make method what would return identical result whit this one in Java, but have not succeed in it. Have been trying whit fast_md5 and messageDiggest whit all posible charset. Don't know what I am doing wrong.

Heres how I tested whit fast_md5

Map><String, Charset> ch = Charset.availableCharsets();

Iterator<String> ite = ch.keySet().iterator();

while( ite.hasNext() ){

String key = ite.next();

try{

MD5 md5 =new MD5();

try{

md5.Update( number.toLowerCase().getBytes( key ) );

}catch( Exception e ){

System.out.println( key +" error;" );

continue;

}

String hash =md5.asHex();

System.out.println( number +"" +key);

System.out.println( hash );

e.printStackTrace();

}

}

Please help me...

[2146 byte] By [tkta] at [2007-11-26 18:32:52]
# 1
If you post a sample input and output from your C# I will see if I can get a match in Java.
sabre150a at 2007-7-9 6:06:57 > top of Java-index,Security,Cryptography...
# 2
Thanks for reply, but I solved it allready. I got the MD5 correctly, but I was not told that value that was passed to that method had made some changes before it was gived to method.
tkta at 2007-7-9 6:06:57 > top of Java-index,Security,Cryptography...