473,386 Members | 1,973 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Form sha1.hexdigest to sha1.digest

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

thanks for your help!

Alexandr.
Apr 6 '08 #1
5 8140
How can convert string from sha1.hexdigest() to string that is the
same, like from sha1.digest()
Use binascii.unhexlify.

HTH,
Martin
Apr 6 '08 #2
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.unhexlify.

HTH,
Martin
Or hexdigest_string.decode('hex')
Apr 6 '08 #3
Or hexdigest_string.decode('hex')

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

Regards,
Martin
Apr 6 '08 #4
Martin v. Löwis napisa³(a):
Or hexdigest_string.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).
Apr 6 '08 #5
>>Or hexdigest_string.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").hexdigest().decode("hex")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'str' object has no attribute 'decode'

Regards,
Martin
Apr 6 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Michael Hamm | last post by:
Hi, I'm trying to write a <form> whihc will retrieve a Web page on another server. I have (essentially) this: <form action="http://cgi.cs.indiana.edu/~oracle/digest.cgi"> <input...
1
by: Raghu | last post by:
According to the xml digital signature standard (http://www.w3.org/TR/xmldsig-core/), signature can be one of following: enveloping, enveloped and detached. The standard says that signature element...
4
by: William Wisnieski | last post by:
Hello Everyone, Access 2000 I have a form with multiple pages on it. There is one text field on the third page of the form that I need the user to complete before leaving the form or moving...
2
by: Rafal 'Raf256' Maj | last post by:
Hello, where can I find ready to use functions for hasing into md5 and sha1 ? I.e. ansi C code like: void makeMd5(unsigned char* input, long size, unsigned char* output) { .... } Ready to...
4
by: ruben.de.visscher | last post by:
Hi, I want to make a program that checks the SHA1 message digest of a password from the user with a list of usernames and the corresponding message digests of their passwords. The problem is,...
1
by: durumdara | last post by:
Hi ! I have a problem in Windows. I need to get the filelist in HDD-s, with sha-N value for every file (to see what changed in the past). 1. I see that Python supports the sha-1. But I need...
3
by: DurumDara | last post by:
Hi ! I need to speedup my MD5/SHA1 calculator app that working on filesystem's files. I use the Python standard modules, but I think that it can be faster if I use C, or other module for it. ...
2
by: poolboi | last post by:
hey guys, I've stored password in mysql using SHA1 encryption do i need the module digest::SHA1 when i'm verifying password for user put in?
6
by: LaundroMat | last post by:
Hi - I'm trying to calculate unique hash values for binary files, independent of their location and filename, and I was wondering whether I'm going in the right direction. Basically, the hash...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.