So i have a directory i am getting the hashes for all files in the directory upon writing / adding the hashes for every file to a text document i keep ending up with the same hash 10-100 times over in the document and i can not figure out why php keeps doing this.
Anyone can run this on windows to see for yourself the certutil that the script executes is built into windows so it will work on any windows machine.
<?php $file_path = 'C:\Users\C0n\Desktop\hash-banned.txt'; foreach (glob("R:\backup\Videos\*") as $filename) { exec('CertUtil -hashfile "'.$filename.'" SHA1', $response); $str = str_replace(' ', '', $response[1]); $find_hashes = file($file_path,FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); foreach ($find_hashes as $n1) { if($str == $n1) { echo "duplicate detected"; break; } echo "Hash does not exist so adding " . $str; //hash not found so add to file //if hash string is not empty then write to file if ($str != "") { file_put_contents($file_path, $str . "\n", FILE_APPEND); } } } ?>