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...

