A gem which wraps the md5sum/md5 command line utilities.
Ruby
Switch branches/tags
Nothing to show
Pull request Compare This branch is 1 commit behind Narnach:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
tasks
test
.gitignore
MIT-LICENSE
README.rdoc
Rakefile
init.rb
install.rb
md5_wrapper.gemspec
uninstall.rb

README.rdoc

Md5Wrapper

Md5Wrapper wraps the command line utilities md5sum (Linux) and md5 (Mac). Detecting which utility should be used is based on the RUBY_PLATFORM constant. It allows obtaining the md5 hexdigest of a file and checking that a file has a specific md5 hexdigest. It does not aim to provide all features offered by the md5(sum) utilities, but anyone who needs more features is welcome to add them.

Md5Wrapper can be used as RubyGem or as Rails plugin.

Installation as Rails plugin

From the Rails project root, execute:

script/plugin install git://github.com/Narnach/md5_wrapper.git

Installation as gem

Install the gem by executing:

sudo gem install Narnach-md5_wrapper --remote --source http://gems.github.com

Example

Get the md5 hexdigest for a file.

Md5Wrapper.get_md5sum('foo.txt') #=> 'abcdabcdabcdabcdabcdabcdabcdabcd'

Check the correct md5 hexdigest against a file.

Md5Wrapper.check_md5sum('foo.txt', 'abcdabcdabcdabcdabcdabcdabcdabcd') #=> true

Check an incorrect md5 hexdigest against a file.

Md5Wrapper.check_md5sum('foo.txt', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa') #=> false

Copyright © 2008 Wes Oldenbeuving, released under the MIT license