Skip to content

Instantly share code, notes, and snippets.

@lloyd
Created September 9, 2009 20:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lloyd/184033 to your computer and use it in GitHub Desktop.
Save lloyd/184033 to your computer and use it in GitHub Desktop.
require 'digest/md5'
class FileChecksum
bp_version "1.0.10"
bp_doc "Allows client side MD5 of user selected files."
def md5(bp, args)
begin
contents = File.open(args[:file].realpath, "rb") { |f| f.read }
bp.complete(Digest::MD5.hexdigest(contents))
rescue Exception => err
bp.error("Error", err.to_s)
end
end
bp_doc :md5, "Generate an md5 checksum of a file.
<file: path> The file for which to calculate a checksum."
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment