Created
February 20, 2023 11:26
-
-
Save emmadesilva/cf7e573936293d6240df79d9ca65f40e to your computer and use it in GitHub Desktop.
Generate checksums.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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