Reputation: 387
Consider the snippet:
from Cryptodome.Hash import SHA256
text = b'Jeanny'
print('Hash of', text)
hx = SHA256.new(text).hexdigest()
print(hx)
h = SHA256.new(text).digest()
[print('{0:x}'.format(h[i]), end = '' ) for i in range(0,len(h))]
It prints:
Hash of b'Jeanny'
f51c7dbd56cc25c565f7c7ef951b06121e87e34f2e3bb466e873a2518715fe50
f51c7dbd56cc25c565f7c7ef951b6121e87e34f2e3bb466e873a2518715fe50
Why is it that the second printed string of hex digits misses 0
in position 29?
Upvotes: 0
Views: 1411
Reputation: 798884
Because it's trying to print "06", but you haven't told it to zero-fill the numbers.
Upvotes: 1