Generation of MD5 is slow and missing first char
<p>Currently I am trying to generate an MD5 of a large data file (10mb+). My current logic generates an MD5 but is cutting off the first character of the MD5. Also, the process is fairly slow, taking at least thirty seconds maybe more.</p>

<p>How do I not get it to cut off first char of MD5?</p>

<p>How can I speed the generation process up?</p>

<p><em>UPDATED</em> Current code:</p>

<pre><code>    File PATH = Environment.getExternalStorageDirectory();
    File DATAFILE = new File(PATH + "/stuff/content/" + FILE);

    Context context = MyApp.getAppContext();
    MessageDigest md = MessageDigest.getInstance("MD5");
    FileInputStream fis = new FileInputStream(DATAFILE);
    BufferedInputStream in = new BufferedInputStream(fis);

   // generate MD5
    byte[] dataBytes = new byte[1024];
    int byteCount;
    while ((byteCount = in.read(dataBytes)) &gt; 0) {
        md.update(dataBytes, 0, byteCount);
    }
    byte[] digest = md.digest();

    // convert to readable string
    String MD5;
    StringBuffer hexString = new StringBuffer();
    for (int i=0; i&lt;digest.length; i++)
        hexString.append(Integer.toHexString(0xFF &amp; digest[i]));
    MD5 = hexString.toString();

    Log.i("GENERATED MD5", MD5);
</code></pre>

<p>Result:
02-19 15:44:59.528: I/GENERATED MD5(24222): cd8f8438957ea9db758ddd12d86e2ca</p>

<p>Should be:
"md5":"0cd8f8438957ea9db758ddd12d86e2ca"</p>

<p>Thanks.</p>
