Skip to content

Instantly share code, notes, and snippets.

@lvidarte
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lvidarte/5c39bd3d168fe5f2fa41 to your computer and use it in GitHub Desktop.
Save lvidarte/5c39bd3d168fe5f2fa41 to your computer and use it in GitHub Desktop.
import timeit
import hashlib
def get_hash(passwd, n=100):
hash = passwd
for i in xrange(n):
hash = hashlib.md5(hash).hexdigest()
return hash
def check_passwd(passwd, hash, n=100):
return get_hash(passwd, n) == hash
if __name__ == '__main__':
passwd = "mypassword"
for n in xrange(1, 1001, 10):
print
print passwd, "md5 *", n
tic = timeit.default_timer()
hash = get_hash(passwd, n)
toc = timeit.default_timer()
print "%s %ss" % (hash, toc - tic)
tic = timeit.default_timer()
hash = get_hash(passwd, n)
result = check_passwd(passwd, hash, n)
toc = timeit.default_timer()
print "%s %ss" % (result, toc - tic)
@lvidarte
Copy link
Author

lvidarte commented Nov 8, 2014

mypassword md5 * 1
34819d7beeabb9260a5c854bc85b3e44 5.79357147217e-05s
True 5.48362731934e-05s

mypassword md5 * 11
abef851a5926fe48fa84731cef19a240 0.000150918960571s
True 0.000290870666504s

mypassword md5 * 21
8a88ed587087a54a81404d3429f4f98d 0.000226020812988s
True 0.000288009643555s

mypassword md5 * 31
60231c316ecc6091363527878fccd087 0.000210046768188s
True 0.000410079956055s

mypassword md5 * 41
d4ff954ce2be07f75c0028da1b4bed55 0.000436067581177s
True 0.000613212585449s

mypassword md5 * 51
2a4d54caa650a9d52551d57a3b2065f0 0.000345945358276s
True 0.000669956207275s

mypassword md5 * 61
89d59fcb3422d97bfe1003f8e6d66323 0.000473022460938s
True 0.000806093215942s

mypassword md5 * 71
68d2006442058968e2ae034672daf5d3 0.000460863113403s
True 0.00101613998413s

mypassword md5 * 81
9882d39000680cd7fa4496bff37ee5c3 0.000586032867432s
True 0.00103998184204s

mypassword md5 * 91
b8887e3d10a7e9fe9e8ddc064cffa12a 0.000586986541748s
True 0.00134015083313s

mypassword md5 * 101
4f58236a3225d5050222df90c44d820c 0.000662088394165s
True 0.00129818916321s

mypassword md5 * 111
f0b764a6a15cc7086bbb01defe4ac35c 0.000802040100098s
True 0.00177383422852s

mypassword md5 * 121
0a5bba2cca9bc244c5bd794b5484e578 0.000795125961304s
True 0.00154495239258s

mypassword md5 * 131
d9332bb65b367f96d647fc1a3efc9a26 0.000897884368896s
True 0.00169014930725s

mypassword md5 * 141
b5250bd4da1c583f66ff3e54e37131c5 0.000898122787476s
True 0.00185203552246s

mypassword md5 * 151
0f4a3041155cd41d091d57ba73acfaf8 0.00101590156555s
True 0.00201201438904s

mypassword md5 * 161
4bf0c8ce9604ec58a8cf55e1fff44fc4 0.00106191635132s
True 0.00206279754639s

mypassword md5 * 171
439ae1ef57fcba987b7a82b46efb3b38 0.00114297866821s
True 0.00222516059875s

mypassword md5 * 181
f7a945a266e8e3dff06fac0c2e848e8c 0.00140905380249s
True 0.00240707397461s

mypassword md5 * 191
3a63def2185f7a442e5382b301fa4ea9 0.00181698799133s
True 0.00248193740845s

mypassword md5 * 201
39d2efbd84797fe6bbee3b5dc4a5c5aa 0.00146198272705s
True 0.0027129650116s

mypassword md5 * 211
2e36e89e699d1696c13162c3c5f9216d 0.00143909454346s
True 0.00273394584656s

mypassword md5 * 221
363a8a17a17977cd65b83dcf5c9ccdee 0.00179100036621s
True 0.00296998023987s

mypassword md5 * 231
4cfafeb88869fa3ed6cfb2834367a898 0.00156497955322s
True 0.0030210018158s

mypassword md5 * 241
5d586845d94201e675f412346358a4fa 0.00156211853027s
True 0.00324988365173s

mypassword md5 * 251
bb2d538af413c6ac6981943dc1f38670 0.00169897079468s
True 0.00330901145935s

mypassword md5 * 261
d74ad79171f51e983c0de0864ee4cff7 0.00173902511597s
True 0.00341796875s

mypassword md5 * 271
e4a6a4d4ea3d44b0bb13f886d5095ab8 0.00204801559448s
True 0.0042679309845s

mypassword md5 * 281
7461245a1e45caf28236e57fa15127ac 0.00244688987732s
True 0.00392389297485s

mypassword md5 * 291
7ef076005c64f83a9c74df458b4f3618 0.00196886062622s
True 0.00388503074646s

mypassword md5 * 301
a16f0172176eed35727cbc1f38c722db 0.00205492973328s
True 0.0039439201355s

mypassword md5 * 311
ed51960e434de7e7335351971ff0b3fb 0.00200700759888s
True 0.00417399406433s

mypassword md5 * 321
03b2a32e469e432d495b08f5fd39b98d 0.00225710868835s
True 0.00470209121704s

mypassword md5 * 331
e0916d8a2e6c98753303a879640b1c17 0.00224089622498s
True 0.00438094139099s

mypassword md5 * 341
5413e10da7467deb3fc79b76b9de965c 0.00216507911682s
True 0.00460004806519s

mypassword md5 * 351
32b1aa57408f54a4c6d953f5dcfa675d 0.00240588188171s
True 0.00501298904419s

mypassword md5 * 361
23fef46a00de5984305ef254c4c3ffa6 0.00266313552856s
True 0.00483298301697s

mypassword md5 * 371
6aa06f2a695864d9f1a444931f9fbdf4 0.00246000289917s
True 0.00638198852539s

mypassword md5 * 381
6bd59aeb514019f178feb471b6a037d0 0.00252318382263s
True 0.00641703605652s

mypassword md5 * 391
c02f9c8f9c333d553a74fac27e7d0fb6 0.00346088409424s
True 0.00546503067017s

mypassword md5 * 401
8675d20876c6ae211a8340605678af8c 0.002769947052s
True 0.00564002990723s

mypassword md5 * 411
fde1a68ec68d281317427f0f72cc0df7 0.0028760433197s
True 0.00635695457458s

mypassword md5 * 421
278b57e594fce6589a774018f2771bc0 0.0029079914093s
True 0.00556492805481s

mypassword md5 * 431
8ebf4807428c0da65301d51c2fc5be2f 0.00417113304138s
True 0.00597214698792s

mypassword md5 * 441
4e73a5646e23cf9724ab9ebe7f757529 0.00308299064636s
True 0.00583791732788s

mypassword md5 * 451
5b35e2ad4bbaf9d6f7c732b6352b2b7e 0.00380110740662s
True 0.00609111785889s

mypassword md5 * 461
9e905db22c695ebfc43f17b4c96d671e 0.00378918647766s
True 0.010810136795s

mypassword md5 * 471
3808538ba8bd274ae7cb9a5671e94bea 0.00573992729187s
True 0.0112979412079s

mypassword md5 * 481
e7586d1321fc2083772cc78d51f16831 0.00601100921631s
True 0.0123569965363s

mypassword md5 * 491
d436e807e495b844ac79d33a4281714f 0.0062952041626s
True 0.0116820335388s

mypassword md5 * 501
8d7da1f10c9ec735edc4ac81a75c8b66 0.0063259601593s
True 0.01265001297s

mypassword md5 * 511
266de325d05169253c6afc83e0ffa858 0.00686383247375s
True 0.0136489868164s

mypassword md5 * 521
3861e81b2f4494e318351aae16784e27 0.00599813461304s
True 0.0072820186615s

mypassword md5 * 531
24cb594e8608da4b9b499c52be3fba00 0.00353598594666s
True 0.00718283653259s

mypassword md5 * 541
7277b48979d99e319123d5aba2c1310e 0.00408792495728s
True 0.00733399391174s

mypassword md5 * 551
d303d4c7d899e6b5066c2dd739a41ec0 0.00370502471924s
True 0.0109331607819s

mypassword md5 * 561
858f355b0366070ab8da665488d0f000 0.00702309608459s
True 0.0143809318542s

mypassword md5 * 571
f62203b6ac4ff8127564c212a22fbec8 0.00765705108643s
True 0.015184879303s

mypassword md5 * 581
3e7ed699c778c835f074991dc97b2364 0.00418591499329s
True 0.00805997848511s

mypassword md5 * 591
5a5bd0a64c8fb77f411cec8cb3bc009b 0.00394105911255s
True 0.00769996643066s

mypassword md5 * 601
781bbe8327e65209702e398c437c3e2e 0.00413513183594s
True 0.00820302963257s

mypassword md5 * 611
a807ffc1f7b1f42fbb3273e4c5e91b2a 0.004065990448s
True 0.00812697410583s

mypassword md5 * 621
7aa59bca8646b7483c9c48ace06ec45b 0.00432300567627s
True 0.0083281993866s

mypassword md5 * 631
e667dcf9ef1629746f6703ef4e5780f7 0.00506901741028s
True 0.00896096229553s

mypassword md5 * 641
970061250cb02b2887014c0a6cb79a47 0.0101680755615s
True 0.017306804657s

mypassword md5 * 651
b43a00af5fb1dcd15cbc678741bf5faf 0.00874614715576s
True 0.018079996109s

mypassword md5 * 661
0aa02ba90cd86f18c8ae4e3a88b5eec6 0.00940895080566s
True 0.0185990333557s

mypassword md5 * 671
3530040b47ac9ada745879adf07549a2 0.00896096229553s
True 0.0189380645752s

mypassword md5 * 681
baf5389d3117ec0b360ae8517e900523 0.0092658996582s
True 0.0196578502655s

mypassword md5 * 691
b54fbc0d8ec3e5ae42604b3714e8c441 0.00979804992676s
True 0.0194540023804s

mypassword md5 * 701
c89142214a10ee76b41860a4491adb5f 0.00941395759583s
True 0.0188398361206s

mypassword md5 * 711
4894ed515c00edd473cb23d152878822 0.00928711891174s
True 0.0148298740387s

mypassword md5 * 721
02116fb176e5ada90b0cda5ec1e57894 0.0083589553833s
True 0.0160839557648s

mypassword md5 * 731
ca2b1a2a752704266110fb4fee034816 0.00845503807068s
True 0.0162949562073s

mypassword md5 * 741
ca1dd3dbb0abbc9413ef91c44ae03e1c 0.00782513618469s
True 0.0113520622253s

mypassword md5 * 751
6e07d075235fe3063e5d48b3892832e0 0.00530314445496s
True 0.0104899406433s

mypassword md5 * 761
3d23bc9e47402b7ebd83ac5e9111eecc 0.00504899024963s
True 0.0107278823853s

mypassword md5 * 771
99023addea2c0cb137f075d7de016c62 0.00520706176758s
True 0.011106967926s

mypassword md5 * 781
eeea7d56109e6ac5ad8e0d92c90d4dbb 0.00535488128662s
True 0.0103998184204s

mypassword md5 * 791
e3be6e6a53f0f101539a047aee0b6c77 0.00802493095398s
True 0.0186219215393s

mypassword md5 * 801
6cc637d59bca9ff686c0e49171d68673 0.00572085380554s
True 0.011815071106s

mypassword md5 * 811
9c641cce7bbef46d47612bada87e445b 0.00565481185913s
True 0.0180110931396s

mypassword md5 * 821
73c11a85c7a1ede681eedae254b721ad 0.0103969573975s
True 0.0208239555359s

mypassword md5 * 831
5a21fdda8dc37b1190065453b4b58aba 0.0087149143219s
True 0.0110199451447s

mypassword md5 * 841
5c43b39667ffa2f0016617ebe7668a07 0.00937819480896s
True 0.0111660957336s

mypassword md5 * 851
5325c1cc6cdefe33ff8de5fc5b62449b 0.00692105293274s
True 0.0115461349487s

mypassword md5 * 861
b87372d65f61de38b5c7aed4481fcafa 0.00606298446655s
True 0.0114419460297s

mypassword md5 * 871
99326445b337473ee5608cb1745610a9 0.00931906700134s
True 0.0131359100342s

mypassword md5 * 881
c9e75dfcbda21b55463736ebf04f6769 0.00816798210144s
True 0.025573015213s

mypassword md5 * 891
55c1d773ce06e7d3849612b57a6f4985 0.0119738578796s
True 0.0233738422394s

mypassword md5 * 901
16e6bbfb2fc62c367f4fdc017d6f8340 0.0123789310455s
True 0.028153181076s

mypassword md5 * 911
837e1d7e8cdfea7376ae0635823b9b57 0.0123820304871s
True 0.0260589122772s

mypassword md5 * 921
53692d1175411def0f73e0b7d5f80e2d 0.0126190185547s
True 0.0251159667969s

mypassword md5 * 931
8779845366d99adb3997ad84eafc275d 0.012992143631s
True 0.0253460407257s

mypassword md5 * 941
53281bcf834f538160a13549ac70d592 0.0117671489716s
True 0.0228610038757s

mypassword md5 * 951
ec6bc470e35d01f90eae9076d78a52b1 0.0109419822693s
True 0.024276971817s

mypassword md5 * 961
300776cf79ce63ece80aef8d3f1ebb44 0.0121059417725s
True 0.0241301059723s

mypassword md5 * 971
32787278baef75e2f19318eeafc34359 0.0120580196381s
True 0.0270068645477s

mypassword md5 * 981
264c1cfea0fbfee9140bdec70cdfb15f 0.0124671459198s
True 0.0249590873718s

mypassword md5 * 991
09bd576351ca4734c2ca8cf0268054c6 0.0132899284363s
True 0.0253989696503s

mypassword md5 * 1001
ef440354826aaa8b51c2271284042986 0.0144391059875s
True 0.0180559158325s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment