hashlib in one line

T

Thomas Guettler

Hi,

I think it would be nice if you could use the hashlib in one line:

hashlib.sha256().update('abc').hexdigest()

Unfortunately update() returns None.

Is there a way to convert a string to the hexdigest of sha256 in one line?

Thomas
 
J

J. Gerlach

Am 29.11.2010 14:50, schrieb Thomas Guettler:
Hi,

I think it would be nice if you could use the hashlib in one line:

hashlib.sha256().update('abc').hexdigest()

Unfortunately update() returns None.

Is there a way to convert a string to the hexdigest of sha256 in one line?

Thomas
Yeah, something like this would be nice: ;)

hashlib.sha256('abc').hexdigest()

(tested in 2.6.6)
 
S

Stefan Sonnenberg-Carstens

Am 29.11.2010 14:50, schrieb Thomas Guettler:
Hi,

I think it would be nice if you could use the hashlib in one line:

hashlib.sha256().update('abc').hexdigest()

Unfortunately update() returns None.

Is there a way to convert a string to the hexdigest of sha256 in one line?

Thomas
Like so ?
'ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,168
Messages
2,570,914
Members
47,455
Latest member
Delilah Code

Latest Threads

Top