Click here to Skip to main content
15,886,835 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Java
public class ChecksumMD5 {


    public static String getValue(String s)
        throws Exception
    {
        String result = "";
        byte b[] = (byte[])null;
        InputStream fis = new ByteArrayInputStream(s.getBytes());
        byte buffer[] = new byte[1024];
        MessageDigest complete = MessageDigest.getInstance("MD5");
        int numRead;
        do
        {
            numRead = fis.read(buffer);
            if(numRead > 0)
                complete.update(buffer, 0, numRead);
        } while(numRead != -1);
        fis.close();
        b = complete.digest();
        for(int i = 0; i < b.length; i++)
            result = (new StringBuilder(String.valueOf(result))).append(Integer.toString((b[i] & 0xff) + 256, 16).substring(1)).toString();

       System.out.println("result111 is--->"+result);
        return result;
    }
}
Posted
Updated 23-Apr-15 21:08pm
v2
Comments
Maciej Los 24-Apr-15 3:08am    
And what's your issue? What have you tried? Where are you stuck?

1 solution

Note that java code is very similar to c# code and it's quite simple to "convert" it. I'd suggest to start here[^] to get bit help ;)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900