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
Changelog
Version 0.3.1
-
Made Md5Wrapper work with filenames with spaces.
Version 0.3.0
-
Md5Wrapper is now available as RubyGem as well as Rails plugin
-
Added a simple test for each method on Md5Wrapper.
-
Renamed generated code to use Md5Wrapper instead of Md5sumWrapper.
-
Added plugin.
Contributors
-
Filip ‘FiXato’ Slagter
Copyright © 2008 Wes Oldenbeuving, released under the MIT license