python之md5使用

python 复制代码
import hashlib

if __name__ == "__main__":
    data = ["3295c76acbf4caaed33c36b1b5fc2cb1", "26657d5ff9020d2abefe558796b99584", "73278a4a86960eeb576a8fd4c9ec6997", "ec8956637a99787bd197eacd77acce5e", "e2c420d928d4bf8ce0ff2ec19b371514", "43ec517d68b6edd3015b3edc9a11367b", "ea5d2f1c4608232e07d3aa3d998e5135", "c8ffe9a587b126f152ed3d89a146b445", "f457c545a9ded88f18ecee47145a72c0", "072b030ba126b2f4b2374f342be9ed44", "c9e1074f5b3f9fc8ea15d152add07294", "c9e1074f5b3f9fc8ea15d152add07294", "03afdbd66e7929b125f8597834fa83a4", "03afdbd66e7929b125f8597834fa83a4", "c9e1074f5b3f9fc8ea15d152add07294", "a97da629b098b75c294dffdc3e463904", "7f39f8317fbdb1988ef4c628eba02591", "7f6ffaa6bb0b408017b62254211691b5", "7f6ffaa6bb0b408017b62254211691b5", "5ef059938ba799aaa845e1c2e8a762bd", "f7177163c833dff4b38fc8d2872f1ec6", "9f61408e3afb633e50cdf1b20de6f466",
            "e369853df766fa44e1ed0ff613f563bd", "182be0c5cdcd5072bb1864cdee4d3d6e", "069059b7ef840f0c74a814ec9237b6ec", "c8ffe9a587b126f152ed3d89a146b445", "b53b3a3d6ab90ce0268229151c9bde11", "4c56ff4ce4aaf9573aa5dff913df997a", "f7177163c833dff4b38fc8d2872f1ec6", "19ca14e7ea6328a42e0eb13d585e4c22", "ec5decca5ed3d6b8079e2e7e7bacc9f2", "c0c7c76d30bd3dcaefc96f40275bdc0a", "3295c76acbf4caaed33c36b1b5fc2cb1", "a3f390d88e4c41f2747bfa2f1b5f87db", "98f13708210194c475687be6106a3b84", "4e732ced3463d06de0ca9a15b6153677", "ea5d2f1c4608232e07d3aa3d998e5135", "6f4922f45568161a8cdf4ad2299f6d23", "98f13708210194c475687be6106a3b84", "c16a5320fa475530d9583c34fd356ef5", "6ea9ab1baa0efb9e19094440c317e21b", "6ea9ab1baa0efb9e19094440c317e21b", "6f4922f45568161a8cdf4ad2299f6d23", "d1fe173d08e959397adf34b1d77e88d7", "43ec517d68b6edd3015b3edc9a11367b"]
    flag=[i for i in range(45)]
    for i in range(45):
        for j in range(0, 256):
            a_md5 = hashlib.md5()
            a = str(j ^ i)
            a_md5.update(a.encode('utf-8'))
            xor_result = a_md5.hexdigest()
            # print(xor_result)
            if data[i] == xor_result:
                flag[i] = chr(j)
                break
    for element in flag:
        print(element, end='')

模块:hashlib

先将md5的text转换成字符串:a = str(j ^ i)

生成md5对象a_md5:a_md5 = hashlib.md5()

更新字符串,编码成utf-8(字节形式表示):a_md5.update(a.encode('utf-8'))

md5对象生成16进制的md5值:xor_result = a_md5.hexdigest()

相关推荐
周全全1 分钟前
Spring Boot + Vue 基于 RSA 的用户身份认证加密机制实现
java·vue.js·spring boot·安全·php
六月的翅膀4 分钟前
C++:实例访问静态成员函数和类访问静态成员函数有什么区别
开发语言·c++
Domain-zhuo10 分钟前
什么是JavaScript原型链?
开发语言·前端·javascript·jvm·ecmascript·原型模式
SoraLuna11 分钟前
「Mac玩转仓颉内测版24」基础篇4 - 浮点类型详解
开发语言·算法·macos·cangjie
小丁爱养花17 分钟前
前端三剑客(三):JavaScript
开发语言·前端·javascript
生信摆渡32 分钟前
R语言-快速对多个变量取交集
开发语言·数据库·r语言
AiFlutter44 分钟前
Java实现简单的搜索引擎
java·搜索引擎·mybatis
¥ 多多¥1 小时前
c++中mystring运算符重载
开发语言·c++·算法
LKID体1 小时前
Python操作neo4j库py2neo使用(一)
python·oracle·neo4j
Mr.Pascal1 小时前
刚学php序列化/反序列化遇到的坑(攻防世界:Web_php_unserialize)
开发语言·安全·web安全·php