Announcement

Collapse
No announcement yet.

(PHP) MD5 generator for a folder?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • (PHP) MD5 generator for a folder?

    Does anyone know of an easy PHP script to just toss in a directory on a web server to see the md5 hash values of each file?
    Quakeone.com - Being exactly one-half good and one-half evil has advantages. When a portal opens to the antimatter universe, my opposite is just me with a goatee.

    So while you guys all have to fight your anti-matter counterparts, me and my evil twin will be drinking a beer laughing at you guys ...

  • #2
    Should be super simple with scandir and md5_file. Let me try.

    Code:
    <?php
    $files = scandir(".");
    
    // remove . and ..
    array_shift($files);
    array_shift($files);
    
    foreach( $files as $file ){
    	$md5sum = md5_file($file);
    	echo $md5sum." ".$file."<br />\n";
    }
    ?>
    Of course this is not practical as dynamic public script, you would need to store the md5sums somewhere. Depends what you mean and what you need.
    Last edited by Spirit; 08-20-2009, 06:38 AM.
    Quake 1 Singleplayer Maps and Mods

    Comment


    • #3
      Looks like that is simple and should work for my uses. I've found lately I've been backing up a lot of Quake files and get increasingly paranoid that something valuable could be corrupted even with a FTP client that supports resume and so forth.

      Thanks! I think you've been ahead of the curve adopting "quality control" methods to ensure archives and files are what they are supposed to be
      Quakeone.com - Being exactly one-half good and one-half evil has advantages. When a portal opens to the antimatter universe, my opposite is just me with a goatee.

      So while you guys all have to fight your anti-matter counterparts, me and my evil twin will be drinking a beer laughing at you guys ...

      Comment


      • #4
        Originally posted by Spirit View Post
        Code:
        <?php
        $files = scandir(".");
        
        // remove . and ..
        array_shift($files);
        array_shift($files);
        
        foreach( $files as $file ){
        	$md5sum = md5_file($file);
        	echo $md5sum." ".$file."<br />\n";
        }
        ?>
        damnit that's just what i was going to say!

        Comment

        Working...
        X