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 772067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:45:11+00:00 2026-05-14T18:45:11+00:00

I currently use md5_file() to run through about 15 URLs and verify their MD5

  • 0

I currently use md5_file() to run through about 15 URLs and verify their MD5 hashes. Is there a way that I can make this faster? It takes far too long to run through all of them.

  • 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-05-14T18:45:11+00:00Added an answer on May 14, 2026 at 6:45 pm

    Probably you’re doing it sequentially right now. I.e. fetch data 1, process data1, fetch data 2, process data 2, … and the bottleneck might be the data transfer.
    You could use curl_multi_exec() to parallelize that a bit.
    Either register a CURLOPT_WRITEFUNCTION and process each chunk of data (tricky since md5() works on exactly one chunk of data).
    Or check for curl handles that are already finished and then process the data of that handle.

    edit: quick&dirty example using the hash extension (which provides functions for incremental hashes) and a php5.3+ closure:

    $urls = array(
      'http://stackoverflow.com/',
      'http://sstatic.net/so/img/logo.png',
      'http://www.gravatar.com/avatar/212151980ba7123c314251b185608b1d?s=128&d=identicon&r=PG',
      'http://de.php.net/images/php.gif'
    );
    
    $data = array();
    $fnWrite = function($ch, $chunk) use(&$data) {
      foreach( $data as $d ) {
        if ( $ch===$d['curlrc'] ) {
          hash_update($d['hashrc'], $chunk);
        }
      }
    };
    
    $mh = curl_multi_init();
    foreach($urls as $u) {
      $current = curl_init();
      curl_setopt($current, CURLOPT_URL, $u);
      curl_setopt($current, CURLOPT_RETURNTRANSFER, 0);
      curl_setopt($current, CURLOPT_HEADER, 0);
      curl_setopt($current, CURLOPT_WRITEFUNCTION, $fnWrite);
      curl_multi_add_handle($mh, $current);
      $hash = hash_init('md5');
      $data[] = array('url'=>$u, 'curlrc'=>$current, 'hashrc'=>$hash); 
    }
    
    $active = null;
    //execute the handles
    do {
      $mrc = curl_multi_exec($mh, $active);
    } while ($mrc == CURLM_CALL_MULTI_PERFORM);
    
    while ($active && $mrc == CURLM_OK) {
      if (curl_multi_select($mh) != -1) {
        do {
          $mrc = curl_multi_exec($mh, $active);
        } while ($mrc == CURLM_CALL_MULTI_PERFORM);
      }
    }
    
    foreach($data as $d) {
      curl_multi_remove_handle($mh, $d['curlrc']);
      echo $d['url'], ': ', hash_final($d['hashrc'], false), "\n";
    }
    curl_multi_close($mh);
    

    (haven’t checked the results though …it’s only a starting point)

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

Sidebar

Related Questions

I currently use: BufferedReader input = new BufferedReader(new FileReader(filename)); Is there a faster way?
I currently use the free obfuscation tool that ships with VS and it does
I need a hash that can be represented in less than 26 chars Md5
It is currently said that MD5 is partially unsafe. Taking this into consideration, I'd
I currently use Zend_Db to manage my queries $stmt = $db->prepare(INSERT INTO test (ID_Test)
I currently use Devise 2.1 + Rails 3.2.x to authenticate users. I'm also going
I currently use the rectangle shape xml tag to specify borders for my views
I currently use a combination of LVL and Proguard as a first line of
I currently use mysql_real_escape_string to escape a variable when querying the database to prevent
I currently use Berkeley DBs fronted by a Java server for a high-performance disk-backed

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.