Skip to content

Instantly share code, notes, and snippets.

@rob-murray
Last active January 7, 2022 20:00
Show Gist options
  • Save rob-murray/5999138 to your computer and use it in GitHub Desktop.
Save rob-murray/5999138 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
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
@farlin
Copy link

farlin commented Apr 28, 2021

thank you! works like charm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment