-
-
Save angrygorilla/199f4644a37a4416cd394efc7b0e2841 to your computer and use it in GitHub Desktop.
Generate a base64 encoded md5 hash of a file in Ruby for use in http Content-MD5 header
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
| require 'digest' | |
| def main | |
| raise ArgumentError, 'Please specify a file to work with' unless ARGV.length == 1 | |
| file_path = ARGV[0] | |
| digest = Digest::MD5.base64digest(File.read( file_path )) | |
| puts "The MD5 digest base64 encoded MD5 is #{digest} of file #{file_path}." | |
| end | |
| if __FILE__ == $0 | |
| main() | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment