Calculate the md5 hash of a string


(Dirk Einecke) #1

Hi.

How can I calculate the md5 hash of a string (like in PHP -
http://de2.php.net/manual/en/function.md5.php)? I can’t find any
helpfull documentation about this problem.

bye
Dirk Einecke


(matthew c. mead) #2

require 'digest/md5'
Digest::MD5.hexdigest(str)

-matt

···

On Sat, Feb 28, 2004 at 03:29:45AM +0900, Dirk Einecke wrote:

Hi.

How can I calculate the md5 hash of a string (like in PHP -
http://de2.php.net/manual/en/function.md5.php)? I can't find any
helpfull documentation about this problem.

bye
Dirk Einecke

--
matthew c. mead

http://www.goof.com/~mmead/


(Jim Freeze) #3

require 'md5’
MD5.md5(“fred”) #=> 570a90bfbf8c7eab5dc5d4e26832d5b1

···

On Saturday, 28 February 2004 at 3:29:45 +0900, Dirk Einecke wrote:

Hi.

How can I calculate the md5 hash of a string (like in PHP -
http://de2.php.net/manual/en/function.md5.php)? I can’t find any
helpfull documentation about this problem.


Jim Freeze

The birds are singing, the flowers are budding, and it is time for Miss
Manners to tell young lovers to stop necking in public.

It’s not that Miss Manners is immune to romance. Miss Manners has been
known to squeeze a gentleman’s arm while being helped over a curb, and,
in her wild youth, even to press a dainty slipper against a foot or two
under the dinner table. Miss Manners also believes that the sight of
people strolling hand in hand or arm in arm or arm in hand dresses up a
city considerably more than the more familiar sight of people shaking
umbrellas at one another. What Miss Manners objects to is the kind of
activity that frightens the horses on the street …


(Wesley J Landaker) #4

irb(main):001:0> require ‘md5’
=> true
irb(main):002:0> MD5.digest(“test”)
=> "\t\217k\315F!\323s\312\336N\203&’\264\366"
irb(main):003:0> MD5.hexdigest(“test”)
=> "098f6bcd4621d373cade4e832627b4f6"
irb(main):004:0> md5 = MD5.new
=> d41d8cd98f00b204e9800998ecf8427e
irb(main):005:0> md5.update(“te”)
=> 569ef72642be0fadd711d6a468d68ee1
irb(main):006:0> md5 << “st”
=> 098f6bcd4621d373cade4e832627b4f6


Wesley J. Landaker wjl@icecavern.net
OpenPGP FP: 4135 2A3B 4726 ACC5 9094 0097 F0A9 8A4C 4CD6 E3D2

···

On Friday 27 February 2004 11:29 am, Dirk Einecke wrote:

Hi.

How can I calculate the md5 hash of a string (like in PHP -
http://de2.php.net/manual/en/function.md5.php)? I can’t find any
helpfull documentation about this problem.


(Dennis Ranke) #5

I can’t find any (real) documentation, either, but:

irb(main):001:0> require ‘digest/md5’
=> true
irb(main):002:0> Digest::MD5.new(‘apple’) ==
‘1f3870be274f6c49b3e31a0c6728957f’
=> true

HTH

···

On Fri, 27 Feb 2004 19:25:06 +0100, Dirk Einecke dirk.einecke@gmx.de wrote:

How can I calculate the md5 hash of a string (like in PHP -
http://de2.php.net/manual/en/function.md5.php)? I can’t find any
helpfull documentation about this problem.


exoticorn/farbrausch


(Dirk Einecke) #6

Hi.

Dirk Einecke wrote:

How can I calculate the md5 hash of a string (like in PHP -
http://de2.php.net/manual/en/function.md5.php)? I can’t find any
helpfull documentation about this problem.

Thank you all for you help.

bye
Dirk Einecke


(Jim Freeze) #7

Go to:
http://www.ruby-doc.org/stdlib/

and click on digest in the left-hand frame and then MD5 in
the top center frame.

···

On Saturday, 28 February 2004 at 3:39:46 +0900, Dennis Ranke wrote:

On Fri, 27 Feb 2004 19:25:06 +0100, Dirk Einecke dirk.einecke@gmx.de > wrote:

I can’t find any (real) documentation, either, but:


Jim Freeze

Bureaucrat, n.:
A person who cuts red tape sideways.
– J. McCabe


(Dennis Ranke) #8

Actually I did just that to be able to guess how to calculate the hash and
it’s certainly much better than no documentation at all, but it’s not
what I’d call ‘real’ documentation for the module.

···

On Sat, 28 Feb 2004 03:43:46 +0900, Jim Freeze jim@freeze.org wrote:

On Saturday, 28 February 2004 at 3:39:46 +0900, Dennis Ranke wrote:

I can’t find any (real) documentation, either, but:

Go to:
http://www.ruby-doc.org/stdlib/

and click on digest in the left-hand frame and then MD5 in
the top center frame.


exoticorn/farbrausch


(Gavin Sinclair) #9

There’s ruby/ext/digest/digest.txt in the source distribution, which
I’ll fold into the source code one day, whereupon it will appear in
the the above-linked documentation.

Cheers,
Gavin

···

On Saturday, February 28, 2004, 5:54:45 AM, Dennis wrote:

On Sat, 28 Feb 2004 03:43:46 +0900, Jim Freeze jim@freeze.org wrote:

On Saturday, 28 February 2004 at 3:39:46 +0900, Dennis Ranke wrote:

I can’t find any (real) documentation, either, but:

Go to:
http://www.ruby-doc.org/stdlib/

and click on digest in the left-hand frame and then MD5 in
the top center frame.

Actually I did just that to be able to guess how to calculate the hash and
it’s certainly much better than no documentation at all, but it’s not
what I’d call ‘real’ documentation for the module.