Created
July 26, 2012 10:21
-
-
Save kfatehi/3181369 to your computer and use it in GitHub Desktop.
Check known md5sum ubuntu/OSX
This file contains 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/env ruby | |
target = ARGV[0] | |
known_md5 = "73d2bd14bd37c5877bdc6c1fbfa66dd5" | |
puts "Checking if #{target} has md5 of #{known_md5}" | |
prog = !`which md5sum`.empty? ? 'md5sum' : (!`which md5`.empty? ? "md5" : raise) | |
test_md5 = `#{prog} #{target}` | |
found = test_md5.match(/#{known_md5}/) | |
puts "#{prog} reports positive match: #{found ? "YES" : "NO"}" | |
## Usage: | |
# ruby validate.rb <file> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment