Explorar el Código

md5 fix

master
Roderic Day hace 4 años
padre
commit
34abb98ca4
Se han modificado 1 ficheros con 6 adiciones y 2 borrados
  1. +6
    -2
      y2016/p05.py

+ 6
- 2
y2016/p05.py Ver fichero

@@ -1,3 +1,4 @@
import itertools
import sys

import toolkit
@@ -6,11 +7,14 @@ import toolkit
text = sys.stdin.read().strip()
password1 = ['_' for _ in range(8)]
password2 = ['_' for _ in range(8)]
for string, digest in toolkit.md5gen(f'{text}{{i}}', pattern=r'00000.+'):
for i in itertools.count():
digest = toolkit.md5(f'{text}{i}')
if not digest.startswith('00000'):
continue
if '_' in password1:
password1[password1.index('_')] = digest[5]
if digest[5] in '01234567' and password2[int(digest[5])] == '_':
password2[int(digest[5])] = digest[6]
print(digest, string, ''.join(password1), ''.join(password2))
print(digest, ''.join(password1), ''.join(password2))
if '_' not in password1 + password2:
break

Cargando…
Cancelar
Guardar