From: Chris Shea Date: 2007-03-30T14:25:05+09:00 Subject: Re: How to md5 a string? On Mar 29, 11:18 pm, "Chris Shea" wrote: > On Mar 29, 11:06 pm, Bontina Chen wrote: > > > > > Chris Shea wrote: > > > On Mar 29, 9:13 pm, Bontina Chen wrote: > > > >> -- > > >> Posted viahttp://www.ruby-forum.com/. > > > > It might be informative to see some examples what you're getting with > > > Digest/MD5 vs other tools. I've used Digest/MD5 with great success on > > > Windows. > > > > If what you're doing is getting the MD5 of a file, opening it for > > > reading in binary mode is done like so: > > > > File.new('filename','rb') > > > > Chris > > > s="http://pandora.com" > > Digest::MD5.hexdigest(s) > > > Abon > > > -- > > Posted viahttp://www.ruby-forum.com/. > > C:\>ruby -v > ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32] > C:\>irb > irb(main):001:0> require 'digest/md5' > => true > irb(main):002:0> s = "http://pandora.com" > => "http://pandora.com" > irb(main):003:0> Digest::MD5.hexdigest(s) > => "9e565e1adf52310555fa2dc1391ded64" > > -- > > mvb:~ cms$ ruby -v > ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-darwin8.9.1] > mvb:~ cms$ irb > irb(main):001:0> require 'digest/md5' > => true > irb(main):002:0> s = "http://pandora.com" > => "http://pandora.com" > irb(main):003:0> Digest::MD5.hexdigest(s) > => "9e565e1adf52310555fa2dc1391ded64" > > -- > > I get the same result fromhttp://www.xs4all.nl/~jlpoutre/BoT/Javascript/Utils/md5_hashing.html > > Can you give a more detailed description of what you're experiencing? > > Chris Oh hell, while I'm at it: ~$ ruby -v ruby 1.8.4 (2005-12-24) [i486-linux] ~$ irb irb(main):001:0> require 'digest/md5' => true irb(main):002:0> s = "http://pandora.com" => "http://pandora.com" irb(main):003:0> Digest::MD5.hexdigest(s) => "9e565e1adf52310555fa2dc1391ded64" -- chris[~]$ ruby -v ruby 1.8.5 (2006-12-25 patchlevel 12) [i686-linux] chris[~]$ irb irb(main):001:0> require 'digest/md5' => true irb(main):002:0> s = "http://pandora.com" => "http://pandora.com" irb(main):003:0> Digest::MD5.hexdigest(s) => "9e565e1adf52310555fa2dc1391ded64"