Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7823633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:19:02+00:00 2026-06-02T08:19:02+00:00

I am trying to match the md5sum of a downloaded file from server. Processing

  • 0

I am trying to match the md5sum of a downloaded file from server.
Processing will be continued only if sums match.

try {
      MessageDigest digest = MessageDigest.getInstance("MD5");
      File f = new File(fileName);
      InputStream is = new FileInputStream(f);              
      byte[] buffer = new byte[8192];
      int read = 0;
      while( (read = is.read(buffer)) > 0) {
          digest.update(buffer, 0, read);
      } 
      is.close();
      byte[] md5sum = digest.digest();
      BigInteger bigInt = new BigInteger(1, md5sum);
      output = bigInt.toString(16);
      System.out.println("MD5: " + output);
  } catch(IOException e) {
      throw new RuntimeException("Unable to process file for MD5", e);
  } catch (NoSuchAlgorithmException e) {
    e.printStackTrace();
  }

Above code doesn’t provide the md5sum properly for some files every time.

When i go to console and check md5sum <filename> md5sum is same as that in server. But when same is calculated from code it is yielding a different result.

vimdiff of downloaded file is not providing any diff.. The files are proper after download.

I am unable to see a problem in above code.

I am trying to change the buffer size. But no luck, So i am guessing that it is not because of the buffer size etc.

 byte[] buffer = new byte[8192];

Regards
Dheeraj Joshi

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T08:19:04+00:00Added an answer on June 2, 2026 at 8:19 am

    BigInteger.toString method will escape the leading 0’s as they are not important.

    BigInteger.toString method is deleting leading 0

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to match C style comments form a file, but only if the
I'm trying to match usernames from a file. It's kind of like this: username=asd123
I am trying to match the text contents(character data) of an XML file with
I am trying to match a string only if it is not part of
I am trying to match 190 in the following ~ delimited text file GPSE~21~ADVANCED
Im trying to match only one of each node with a generic match. Can
I am trying to match emails from one of my own sites using a
Trying to match ONLY the first character in the sample below. Sample string: C/C++/Objective
I'm trying to match only when all space-separated words are longer than 3 word
I trying to match a variable from an url. This works fine if I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.