I suspect the issue you are having is that the C# code returns the hash separated with dashes, because you are converting the hash to a GUID, and GUID.ToString()
returns the string in what M$ call "registry format", which is the standard 8-4-4-4-12 string notation of a GUID.
If this is the case, you could achieve the same result with this function:
function md5_guid ($data, isFile = FALSE) {
if ($isFile) {
if (is_file($data) && is_readable($data)) {
$hash = str_split(md5_file($data), 4);
} else {
return FALSE;
}
} else {
$hash = str_split(md5($data), 4);
}
return "$hash[0]$hash[1]-$hash[2]-$hash[3]-$hash[4]-$hash[5]$hash[6]$hash[7]";
}
// Returns the MD5 hash of the string 'this is some data' in the format of a GUID
echo md5_guid('this is some data');
// Returns the MD5 hash of the file at 'somefile.txt' in the format of a GUID
echo md5_guid('somefile.txt', TRUE);