Created
December 6, 2014 20:59
-
-
Save ssajous/0793bb41702169a1302d to your computer and use it in GitHub Desktop.
Calculate the MD5 hash of a file
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
#!/usr/bin/ruby | |
require 'digest/md5' | |
if ARGV[0] && File.exists?(ARGV[0]) | |
STORAGE_PATH = ARGV[0] | |
else | |
puts 'Fatal error: path not existent or not given.' | |
exit | |
end | |
digest = Digest::MD5.file(STORAGE_PATH) | |
puts digest |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage
$ ./md5.rb file.jpg