BBUCTF消失的MD5题解

import hashlib   
for i in range(32,127):
    for j in range(32,127):
        for k in range(32,127):
            m=hashlib.md5()
            m.update('TASC'+chr(i)+'O3RJMV'+chr(j)+'WDJKX'+chr(k)+'ZM')
            des=m.hexdigest()
            if 'e9032' in des and 'da' in des and '911513' in des:
                print des

题目给的代码直接运行会报错,先来了解每个函数的意义,这是个哈希算法。其中

 

m=hashlib.md5()

获取加密对象

m.update('TASC'+chr(i)+'O3RJMV'+chr(j)+'WDJKX'+chr(k)+'ZM')

 制定需要加密的字符,但是题目给的格式是错误的,正确的应为

m.update(('TASC' + chr(i) + 'O3RJMV' + chr(j) + 'WDJKX' + chr(k) + 'ZM').encode('utf-8'))

 

des=m.hexdigest()

获取加密后的字符串。 

把题目给的代码改成正确形式为:

import hashlib
for i in range(32, 127):
    for j in range(32, 127):
        for k in range(32, 127):
            m = hashlib.md5()
            m.update(('TASC' + chr(i) + 'O3RJMV' + chr(j) + 'WDJKX' + chr(k) + 'ZM').encode('utf-8'))
            des = m.hexdigest()
            if 'e9032' in des and 'da' in des and '911513' in des:
                print(des)

运行一下就得到flag了 

你可能感兴趣的:(密码学,python,算法,开发语言)