Answer the question
In order to leave comments, you need to log in
Is there a way to calculate the checksum for a folder?
Good afternoon.
There was a need to calculate the checksum for a folder (for example, MD5).
I couldn't find the answer on Google (maybe I didn't search well).
Is it even possible to do this?
Answer the question
In order to leave comments, you need to log in
function getMd5DirHash(string $dir): string
{
$array = [];
$dir = realpath($dir);
$fileSPLObjects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::CHILD_FIRST);
foreach($fileSPLObjects as $fullFileName => $fileSPLObject ) {
if ($fileSPLObject->isFile()) {
$array[] = $fullFileName;
}
}
$md5 = array_map('md5_file', $array);
return md5(implode('', $md5));
}
$array[] = md5_file($fullFileName);
#$md5 = array_map('md5_file', $array);
return md5(implode('', $array));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question