I'm using hexdigest in Digest/MD5 but got totally different outputs from
other tools.
I got some clues that in windows I should read the source I would like
to hash with binary mode.
But I have no idea how to transform a string to binary mode.
Anyone could give my some suggestion?
Thx
ABon
···
--
Posted via http://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
···
On Mar 29, 9:13 pm, Bontina Chen <abonc...@gmail.com> wrote:
I'm using hexdigest in Digest/MD5 but got totally different outputs from
other tools.
I got some clues that in windows I should read the source I would like
to hash with binary mode.
But I have no idea how to transform a string to binary mode.
Anyone could give my some suggestion?
Thx
ABon
--
Posted viahttp://www.ruby-forum.com/.
Bontina Chen wrote:
I'm using hexdigest in Digest/MD5 but got totally different outputs from
other tools.
I got some clues that in windows I should read the source I would like
to hash with binary mode.
But I have no idea how to transform a string to binary mode.
Anyone could give my some suggestion?
Try:
p my_string.split(//)
and see if you get the same sequence of bytes you expect other
tools to see. Also try "puts my_string.size" to verify the byte
count.
Your sources must be byte-for-byte identical, including any newlines.
e.g.
echo "hello" | md5sum
echo -n "hello" | md5sum
will give different answers.
···
On Fri, Mar 30, 2007 at 12:13:14PM +0900, Bontina Chen wrote:
I'm using hexdigest in Digest/MD5 but got totally different outputs from
other tools.
I got some clues that in windows I should read the source I would like
to hash with binary mode.
But I have no idea how to transform a string to binary mode.
Anyone could give my some suggestion?
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"
···
On Mar 29, 11:06 pm, Bontina Chen <abonc...@gmail.com> wrote:
Chris Shea wrote:
> On Mar 29, 9:13 pm, Bontina Chen <abonc...@gmail.com> 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/.
--
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 from http://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"
···
On Mar 29, 11:18 pm, "Chris Shea" <cms...@gmail.com> wrote:
On Mar 29, 11:06 pm, Bontina Chen <abonc...@gmail.com> wrote:
> Chris Shea wrote:
> > On Mar 29, 9:13 pm, Bontina Chen <abonc...@gmail.com> 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
--
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"