Jump to content

[SOLVED] checking md5checksum of a file using PHP


jst4fun

Recommended Posts

Hi,

I got to code a script which would check the md5 checksum of a file is valid or not. I dont want to run the script as a shell script but using a server side script. I am not sure on how to accomplish the same.  I hope someone would have some idea regarding it and would help me in it. Thank You :)

Hmmm.... I forget exactly how filesums work, but couldn't you do something like:

 

<?php
$checksum = 'blahblahblah'; //ehhh md5 checksum lol

$content = file_get_contents('path/to.file');

$sum = md5($content);

if($sum == $checksum) echo 'Match!';


?>

I think it is working. I took the md5 of the file using md5sum command and compared it with the one we get by using the above script. Both were different  ??? . So I think I should not go for that method. Instead get the md5 sum of the file using the above script, save it and in the future get the stored md5 value of the file and then compare with the one generated by the script above. I think that might work. Thank you corbin.  :) (I may come back. So not marking this thread as solved  ;D )

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.