There is already a inbuilt function to calculate the MD5 Hash of file in PHP.
Example #1 Usage example of md5_file()
<?php
$file="php-5.3.0alpha2-Win32-VC9-x64.zip";
echo 'MD5 file hash of ' . $file . ': ' . md5_file($file);
?>
or if you need to find the MD5 Has for a string then
http://php.net/manual/en/function.md5.php
<?php
$str="apple";
echo 'MD5 hash of ' . $str. ': ' . md5($str);
?>
solved Convert VB.NET code to PHP