我想编写一个Python脚本来实现bruteforce散列,允许用户将散列算法作为字符串插入(结果:
algorithm = "md5"
),但当我尝试在hashlib库中这样使用它时:
guess_hash = hashlib.algorithm(bytes(guess)).hexdigest()
,它显然给了我这个错误:
AttributeError: module 'hashlib' has no attribute 'algorithm'
所以我做了一个快速的研究,我试着像这样使用getattr:
getattr(hashlib,guess(bytes(guess1))).hexdigest()
(可能真的错了)它给了我一个错误:
TypeError: string argument without an encoding
.
我该怎么办?提前谢谢,对不起没有人:)