Skip to content

Instantly share code, notes, and snippets.

@kfatehi
Created July 26, 2012 10:21
Show Gist options
  • Save kfatehi/3181369 to your computer and use it in GitHub Desktop.
Save kfatehi/3181369 to your computer and use it in GitHub Desktop.
Check known md5sum ubuntu/OSX
#!/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