Form sha1.hexdigest to sha1.digest

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

    Form sha1.hexdigest to sha1.digest

    How can convert string from sha1.hexdigest( ) to string that is the
    same, like from sha1.digest()

    thanks for your help!

    Alexandr.
  • =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=

    #2
    Re: Form sha1.hexdigest to sha1.digest

    How can convert string from sha1.hexdigest( ) to string that is the
    same, like from sha1.digest()
    Use binascii.unhexl ify.

    HTH,
    Martin

    Comment

    • marek.rocki@wp.pl

      #3
      Re: Form sha1.hexdigest to sha1.digest

      Martin v. Löwis napisa³(a):
      How can convert string from sha1.hexdigest( ) to string that is the
      same, like from sha1.digest()
      >
      Use binascii.unhexl ify.
      >
      HTH,
      Martin
      Or hexdigest_strin g.decode('hex')

      Comment

      • =?ISO-8859-2?Q?=22Martin_v=2E_L=F6wis=22?=

        #4
        Re: Form sha1.hexdigest to sha1.digest

        Or hexdigest_strin g.decode('hex')

        I would advise against this, as it's incompatible with Python 3.

        Regards,
        Martin

        Comment

        • marek.rocki@wp.pl

          #5
          Re: Form sha1.hexdigest to sha1.digest

          Martin v. Löwis napisa³(a):
          Or hexdigest_strin g.decode('hex')
          >
          I would advise against this, as it's incompatible with Python 3.
          I didn't know that, you actually made me look it up in the Python 3
          FAQ. And yes, the difference is that decode will return bytes type
          instead of a string. This may or may not be a problem (bytes type is
          supposed to be immutable, so it can be used in many places where a
          string is used now, ex. as a dict key).

          Comment

          • =?ISO-8859-2?Q?=22Martin_v=2E_L=F6wis=22?=

            #6
            Re: Form sha1.hexdigest to sha1.digest

            >>Or hexdigest_strin g.decode('hex')
            >I would advise against this, as it's incompatible with Python 3.
            >
            I didn't know that, you actually made me look it up in the Python 3
            FAQ. And yes, the difference is that decode will return bytes type
            instead of a string.
            No. The decode method on string objects is removed, you can only
            *encode* strings, but not decode them.
            This may or may not be a problem
            The problem is this:

            pyhashlib.sha1( b"Hallo").hexdi gest().decode(" hex")
            Traceback (most recent call last):
            File "<stdin>", line 1, in <module>
            AttributeError: 'str' object has no attribute 'decode'

            Regards,
            Martin

            Comment

            Working...