Skip to content

Instantly share code, notes, and snippets.

@emmadesilva
Created February 20, 2023 11:26
Show Gist options
  • Select an option

  • Save emmadesilva/cf7e573936293d6240df79d9ca65f40e to your computer and use it in GitHub Desktop.

Select an option

Save emmadesilva/cf7e573936293d6240df79d9ca65f40e to your computer and use it in GitHub Desktop.
Generate checksums.txt
<?php
$dir = getcwd();
$algos = ['md5', 'sha1', 'sha256', 'sha512'];
$files = explode(',', $argv[1]);
$lines = '';
foreach ($files as $file) {
if (file_exists("$dir/$file")) {
foreach ($algos as $algo) {
$hash = hash_file($algo, "$dir/$file");
$lines .= $algo . ': ' . $hash . "\n";
}
}
}
file_put_contents('checksums.txt', $lines);
echo $lines;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment