python 在CTF密码学中的简单应用

一,base64编码:

import base64
str=b"test"
decode=base64.b64decode(str)
encode=base64.b64encode(decode)

要注意字符串格式为二进制型,在字符串前加b.

同理还有base16,base32编码解码,相应位置替换成16,32即可。

二,MD5加密

import hashlib
str="test"
pass=hashlib.md5(str(m0).encode())
print(pass.hexdigest())

python3中用的是hashlib库,而不是MD5

md5()中传入的字符串要进行encode()操作,将unicode格式改为utr8.



猜你喜欢

转载自blog.csdn.net/zpy1998zpy/article/details/80473641