ok now lets say we have this code

import hashlib,itertools,string
m=hashlib.md5()
s=string.printable
it=itertools.product(s,repeat=1)
for i in it:
    ij="".join(i)
    m.update(ij)
    print ij+"  "+m.hexdigest()
>>
0  cfcd208495d565ef66e7dff9f98764da
1  96a3be3cf272e017046d1b2674a52bd3
2  d2490f048dc3b77a457e3e450ab4eb38
3  eb62f6b9306db575c2d596b1279627a4
4  4100c4d44da9177247e44a5fc1546778
5  d6a9a933c8aafc51e55ac0662b6e4d4a
6  124bd1296bec0d9d93c7b52a71ad8d5b
7  2e9ec317e197819358fbc43afca7d837
8  22975d8a5ed1b91445f6c55ac121505b
9  781e5e245d69b566979b86e28d23f2c7
a  343817fa02440513ce03e9d1f1e44dc7
b  b60c52bf4849067f0b57c8bd30985466
c  2d31d97199fb287d6fcb4f82ebd1b3f2
d  adfff09fa9911d46f1f90ec7a57c256f
e  32a120cc6c02e2be926b4c785c440cd8
f  4032af8d61035123906e58e067140cc5
g  461f13e3e373ff0ab8a219283afe33db
h  52fb8ecb8b966ef584f95d7a12894378
i  3adabbafe7159b777789d849a071cb9e
j  644be06dfc54061fd1e67f5ebbabcd58
k  717b53280326574bd58c304f9fa0c79a
l  6eacdf4a2c58a8227794bcce6f4434e5
m  c42134e9c6c8febd3a1bef7fd3172bb8
n  e787cedbce5704c7b5d69df769867bac
o  c2937d60ca8a158d46d432c525b6e4d5
p  adaa4afb8b399903f2b192eaf1fa4763
q  92c724f26b669f28d0ce83c4343bd3cc
r  3b423c6ce588c9ab049f0617c5896237
s  f245a1194db4b47d474acb3c60c2c774
t  99b26f0aa7ccfc3f0d6bbd650248f1b1
u  6e010733512c5f8042bb945e6fa749f2
v  aa4bc671b4c1c7a38e29800f50ef6346
w  16d6fb5f411119ef58fa9dc5c95c1aa4
x  bf1625a50195ac4e07f1631c1adcb680
y  1f9c90154b925a3eafeba871285b05d1
z  e9b1713db620f1e3a14b6812de523f4b
A  1f6a363d9755874ff79077c9401e03fd
B  38132b10456f91cff46681d741550b00
C  0cd373e119374f4081cfa24f278ffb2b
D  dde00f1a0caed44e7d74c7c326c457a8
E  a4cc3db9ac84043f49eeeca1bd430a73
F  fefdefe2f1a5243586cfb439ec4cd845
G  bfa4196bb5d29346f6cf35d17e37debb
H  1d41b97bea2f38df84637d499f1dcadb
I  65a05c166ee662079372fcf0045769d8
J  8ff55f2e215b5a1a89a21d922ab2dbed
K  9fd388c7e380a595dfb26e963824f347
L  6eb3abbd789b4f3ee50a6f91e6551030
M  b012f940dfd320ca0751323cfbc1e6e3
N  fe471a1474e52d54abeb290e97186f36
O  be453b3a035dedebb134e5ad67096175
P  f7cb119001bdfd4c4263310109ca29cc
Q  ca48f2336ab9c5011c2b4483a6702af1
R  ca7e8be59899af9784c39af1bb98a033
S  973acf0d01534e50a978df916fab03e9
T  7719e3b4fd47a74b8fe113d8e9b2fea3
U  f2f7f58759fde8ceebed9e31b58a5c92
V  b5c2f1ac166feffa0a6d2b93b0551281
W  104c4f9eecde08e0337b8801bbded816
X  775790e274f6c0da075360e17f2b79af
Y  d9ea138a6650fabf277d4a0365003494
Z  b9b3cc3f3a30d8ef2bb1e2e267ed97de
!  e1bd485ebcd644e189a48b8d36d5b5b1
"  65c30c7eb3aa683f35084ae4941d8216
#  8c2424de3993d27d057a69aeb5b898e0
$  c6a909df8245d1c97137eabc6c5484c0
%  fe0639b1a366c7013236fb1181bd8d54
&  afb836c7b59e407a6a671beeef61c0e0
'  855ca43667d2377213c2cfbb54cb3f08
(  84ae66d742e8bbbd69854c98e85de817
)  6ea7c1291c7a59e117d50631d490b480
*  fde3dcf56b68f2822187ac147e2bf40d
+  613a8b25dae55aeb4dd0e805dde7a20d
,  aaeb62b6ccb6895ace0b55e8f69e81b0
-  17ff63b406ffc63598cea7a7330c1db6
.  a13d78760de99910b878b23e2b74710c
/  027df6d5d31830c0dc5dbed9164d3220
:  095f3a0beb0f01e084f7562a701d16e7
;  7c0cf23877d7c94757638dc49a8d8767
<  40e1d62b0fd7850543e0b5e021d374fc
=  509be5256a4dca1cc45bf28edc7b4c04
>  25342ea21de6dd99904443955b911338
?  e024c1b61c5474fbe0945f9ad376450f
@  c9dc108dc8b4a387d85f778c7a5de197
[  6f0f4358e1d866ba5d02eb81e1fe1cf2
\  31bf923b289c520db638315fce35dd8c
]  d1e38eefb0c13331b5bff89e9ca98fe6
^  da5007dedd5ebfb2252d424b8df03892
_  07975522af182abebdbf8499f895ad97
`  5ea85367f5dd67fbce93b6bc7b450a27
{  d013383f17b53343baaee4e5546f4f99
|  16b58b34e2dd71eb96a4b508c166a87e
}  803e113dcf4b5e82c6b1f45e7db2a02b
~  c8aa37f1fd2dbb8f2ea010cc8c7af426
   38a14f98efc9888e920501542aff6d70
      b7494067e37f575b7a3b966ecded25da

  f150f2901013d18c7ce81a78f9d7faa7
  81b2bb19fb81885f032724d579b27876

  6610bbe561df0ee4d42d8e7c5d72699e

  e9060bd3a5987d638ac66399444117d1
>>> 

now lets notice the line a where its md5 is : 343817fa02440513ce03e9d1f1e44dc7
but
in this code:

import hashlib
m=hashlib.md5()
m.update("a")
m.hexdigest()
>>
0cc175b9c0f1b6a831c399e269772661

whats wrong with that??!!

You have only a in second case, but all letters before it also in first case.

hash.update(arg)
Update the hash object with the string arg. Repeated calls are equivalent to a single call with the concatenation of all the arguments: m.update(a); m.update(b) is equivalent to m.update(a+b).

import hashlib, string
for i in string.printable:
    m=hashlib.md5(i)
    print(i+"  "+m.hexdigest())

hmm i thought update() function will delete the value and set a new one .. thanx .. sloved..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.