md5 differences

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Python

    md5 differences

    Hi there!

    I'm trying to match the results of an md5 checksum done in a tcsh shell.
    I keep getting different results and can't find anything on google...

    here's an example:

    Arno@Computer:~ % echo "hello" | md5
    b1946ac92492d23 47c6235b4d26111 84

    Arno@Computer:~ % python
    Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17)
    [GCC 4.0.1 (Apple Inc. build 5465)] on darwin
    Type "help", "copyright" , "credits" or "license" for more information.
    >>import md5
    >>md5.new("hell o").hexdiges t()
    '5d41402abc4b2a 76b9719d911017c 592'


    How do I get the same results?

    thanks
    Arno
  • Richard Brodie

    #2
    Re: md5 differences


    "Python" <python@rgbaz.e uwrote in message
    news:mailman.79 9.1221063937.34 87.python-list@python.org ...
    here's an example:
    Arno@Computer:~ % echo "hello" | md5
    b1946ac92492d23 47c6235b4d26111 84
    How do I get the same results?
    Checksum the same string.
    >>md5.new("hell o\n").hexdigest ()
    'b1946ac92492d2 347c6235b4d2611 184'


    Comment

    • Python

      #3
      Re: md5 differences


      On 10 sep 2008, at 18:30, Richard Brodie wrote:
      >
      "Python" <python@rgbaz.e uwrote in message
      news:mailman.79 9.1221063937.34 87.python-list@python.org ...
      >
      >here's an example:
      >Arno@Computer: ~% echo "hello" | md5
      >b1946ac92492d2 347c6235b4d2611 184
      >How do I get the same results?
      >
      Checksum the same string.
      >
      >>>md5.new("hel lo\n").hexdiges t()
      'b1946ac92492d2 347c6235b4d2611 184'
      >
      >
      hmm and this then:

      Arno@Computer:~ % echo "test" test.txt

      Arno@Computer:~ % md5 test.txt
      MD5 (test.txt) = d8e8fca2dc0f896 fd7cb4cb0031ba2 49

      Arno@Computer:~ % python
      Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17)
      [GCC 4.0.1 (Apple Inc. build 5465)] on darwin
      Type "help", "copyright" , "credits" or "license" for more information.
      >>import md5
      >>md5.new("/Volumes/data/Arno/test.txt").hexd igest()
      '90364ed45b452d 43378629c20543a 81d'


      even
      echo -n "hello" | md5
      doesn't return the same number


      gr
      Arno

      Comment

      • D'Arcy J.M. Cain

        #4
        Re: md5 differences

        On Wed, 10 Sep 2008 19:12:28 +0200
        Python <python@rgbaz.e uwrote:
        hmm and this then:
        >
        Arno@Computer:~ % echo "test" test.txt
        >
        Arno@Computer:~ % md5 test.txt
        MD5 (test.txt) = d8e8fca2dc0f896 fd7cb4cb0031ba2 49
        >
        Arno@Computer:~ % python
        Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17)
        [GCC 4.0.1 (Apple Inc. build 5465)] on darwin
        Type "help", "copyright" , "credits" or "license" for more information.
        >>import md5
        >>md5.new("/Volumes/data/Arno/test.txt").hexd igest()
        '90364ed45b452d 43378629c20543a 81d'
        You're going to smack yourself on the head over this one. :-)
        >>md5.new(open( "/Volumes/data/Arno/test.txt").read ()).hexdigest()
        --
        D'Arcy J.M. Cain <darcy@druid.ne t | Democracy is three wolves
        http://www.druid.net/darcy/ | and a sheep voting on
        +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.

        Comment

        • Wojtek Walczak

          #5
          Re: md5 differences

          On Wed, 10 Sep 2008 19:12:28 +0200, Python wrote:
          Arno@Computer:~ % echo "test" test.txt
          >
          Arno@Computer:~ % md5 test.txt
          MD5 (test.txt) = d8e8fca2dc0f896 fd7cb4cb0031ba2 49
          >import md5
          >md5.new("/Volumes/data/Arno/test.txt").hexd igest()
          '90364ed45b452d 43378629c20543a 81d'

          Works for me:
          >>import md5
          >>f = open('test.txt' ).read()
          >>md5.new(f).he xdigest()
          'd8e8fca2dc0f89 6fd7cb4cb0031ba 249'
          >>>
          IOW, don't pass the path to the file to md5.new, but the contents
          of this file.

          The strange thing is that
          >>md5.new("/Volumes/data/Arno/test.txt").hexd igest()
          returns '8dd66a1592e2a8 c3ab160822fb237 f4d' on my machine.

          --
          Regards,
          Wojtek Walczak,

          Comment

          • Grant Edwards

            #6
            Re: md5 differences

            On 2008-09-10, Python <python@rgbaz.e uwrote:
            >
            On 10 sep 2008, at 18:30, Richard Brodie wrote:
            >
            >>
            >"Python" <python@rgbaz.e uwrote in message
            >news:mailman.7 99.1221063937.3 487.python-list@python.org ...
            >>
            >>here's an example:
            >>Arno@Computer :~% echo "hello" | md5
            >>b1946ac92492d 2347c6235b4d261 1184
            >>How do I get the same results?
            >>
            >Checksum the same string.
            >>
            >>>>md5.new("he llo\n").hexdige st()
            >'b1946ac92492d 2347c6235b4d261 1184'
            >>
            >>
            >
            hmm and this then:
            >
            Arno@Computer:~ % echo "test" test.txt
            >
            Arno@Computer:~ % md5 test.txt
            MD5 (test.txt) = d8e8fca2dc0f896 fd7cb4cb0031ba2 49
            >
            Arno@Computer:~ % python
            Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17)
            [GCC 4.0.1 (Apple Inc. build 5465)] on darwin
            Type "help", "copyright" , "credits" or "license" for more information.
            >import md5
            >md5.new("/Volumes/data/Arno/test.txt").hexd igest()
            '90364ed45b452d 43378629c20543a 81d'
            That's the digest of the string "/Volumes/data/Arno/test.txt".
            It's not supposed to match the digest of the string "test\n".
            >>md5.new(open( "test.txt").rea d()).hexdigest( )
            'd8e8fca2dc0f89 6fd7cb4cb0031ba 249'

            $ md5sum test.txt
            d8e8fca2dc0f896 fd7cb4cb0031ba2 49 test.txt

            $ echo "test" | md5sum
            d8e8fca2dc0f896 fd7cb4cb0031ba2 49 -
            >>md5.new("test \n").hexdigest( )
            'd8e8fca2dc0f89 6fd7cb4cb0031ba 249'
            even
            echo -n "hello" | md5
            doesn't return the same number
            Not the same as _what_?
            >>md5.new("test ").hexdiges t()
            '098f6bcd4621d3 73cade4e832627b 4f6'

            $ echo -n test | md5sum
            098f6bcd4621d37 3cade4e832627b4 f6 -


            --
            Grant Edwards grante Yow! One FISHWICH coming
            at up!!
            visi.com

            Comment

            • Grant Edwards

              #7
              Re: md5 differences

              On 2008-09-10, Wojtek Walczak <gminick@bzt.bz twrote:
              On Wed, 10 Sep 2008 19:12:28 +0200, Python wrote:
              >Arno@Computer: ~% echo "test" test.txt
              >>
              >Arno@Computer: ~% md5 test.txt
              >MD5 (test.txt) = d8e8fca2dc0f896 fd7cb4cb0031ba2 49
              >
              >>import md5
              >>md5.new("/Volumes/data/Arno/test.txt").hexd igest()
              >'90364ed45b452 d43378629c20543 a81d'
              >
              >
              Works for me:
              >
              >>>import md5
              >>>f = open('test.txt' ).read()
              >>>md5.new(f).h exdigest()
              'd8e8fca2dc0f89 6fd7cb4cb0031ba 249'
              >>>>
              >
              IOW, don't pass the path to the file to md5.new, but the contents
              of this file.
              >
              The strange thing is that
              >>>md5.new("/Volumes/data/Arno/test.txt").hexd igest()
              returns '8dd66a1592e2a8 c3ab160822fb237 f4d' on my machine.
              Same here.

              --
              Grant Edwards grante Yow! What PROGRAM are they
              at watching?
              visi.com

              Comment

              • Wojtek Walczak

                #8
                Re: md5 differences

                On Wed, 10 Sep 2008 12:39:24 -0500, Grant Edwards wrote:
                >The strange thing is that
                >>>>md5.new("/Volumes/data/Arno/test.txt").hexd igest()
                >returns '8dd66a1592e2a8 c3ab160822fb237 f4d' on my machine.
                >
                Same here.
                I guess it will be the same for vast majority of us ;-)
                The question is why is it '90364ed45b452d 43378629c20543a 81d'
                for the OP? :-)

                --
                Regards,
                Wojtek Walczak,

                Comment

                • Grant Edwards

                  #9
                  Re: md5 differences

                  On 2008-09-10, Wojtek Walczak <gminick@bzt.bz twrote:
                  On Wed, 10 Sep 2008 12:39:24 -0500, Grant Edwards wrote:
                  >
                  >>The strange thing is that
                  >>>>>md5.new( "/Volumes/data/Arno/test.txt").hexd igest()
                  >>returns '8dd66a1592e2a8 c3ab160822fb237 f4d' on my machine.
                  >>
                  >Same here.
                  >
                  I guess it will be the same for vast majority of us ;-)
                  The question is why is it '90364ed45b452d 43378629c20543a 81d'
                  for the OP? :-)
                  The smart money is betting on "because the OP goofed when he
                  was cutting/pasting stuff from his terminal window into his
                  posting."

                  --
                  Grant Edwards grante Yow! Were these parsnips
                  at CORRECTLY MARINATED in
                  visi.com TACO SAUCE?

                  Comment

                  • Python

                    #10
                    Re: md5 differences


                    On 10 sep 2008, at 19:39, Grant Edwards wrote:
                    On 2008-09-10, Wojtek Walczak <gminick@bzt.bz twrote:
                    >On Wed, 10 Sep 2008 19:12:28 +0200, Python wrote:
                    >>Arno@Computer :~% echo "test" test.txt
                    >>>
                    >>Arno@Computer :~% md5 test.txt
                    >>MD5 (test.txt) = d8e8fca2dc0f896 fd7cb4cb0031ba2 49
                    >>
                    >>>>>import md5
                    >>>>>md5.new( "/Volumes/data/Arno/test.txt").hexd igest()
                    >>'90364ed45b45 2d43378629c2054 3a81d'
                    >>
                    >>
                    >Works for me:
                    >>
                    >>>>import md5
                    >>>>f = open('test.txt' ).read()
                    >>>>md5.new(f). hexdigest()
                    >'d8e8fca2dc0f8 96fd7cb4cb0031b a249'
                    >>>>>
                    >>
                    >IOW, don't pass the path to the file to md5.new, but the contents
                    >of this file.
                    >>
                    >The strange thing is that
                    >>>>md5.new("/Volumes/data/Arno/test.txt").hexd igest()
                    >returns '8dd66a1592e2a8 c3ab160822fb237 f4d' on my machine.
                    >
                    Same here.
                    >
                    --
                    Grant Edwards grante Yow! What PROGRAM
                    are they
                    thanks everyone for helping me out!

                    cheers
                    Arno

                    Comment

                    • Python

                      #11
                      Re: md5 differences


                      On 10 sep 2008, at 19:48, Grant Edwards wrote:
                      On 2008-09-10, Wojtek Walczak <gminick@bzt.bz twrote:
                      >On Wed, 10 Sep 2008 12:39:24 -0500, Grant Edwards wrote:
                      >>
                      >>>The strange thing is that
                      >>>>>>md5.new ("/Volumes/data/Arno/test.txt").hexd igest()
                      >>>returns '8dd66a1592e2a8 c3ab160822fb237 f4d' on my machine.
                      >>>
                      >>Same here.
                      >>
                      >I guess it will be the same for vast majority of us ;-)
                      >The question is why is it '90364ed45b452d 43378629c20543a 81d'
                      >for the OP? :-)
                      >
                      The smart money is betting on "because the OP goofed when he
                      was cutting/pasting stuff from his terminal window into his
                      posting."
                      >
                      I did! I did!

                      my bad... i cut some crap from the path to make it a bit easier to read
                      but that was before the time i knew it was checksumming the
                      actual path in stead of the contents of the file.
                      So I figured it didn't matter...

                      ;)


                      Comment

                      Working...