Python练习题答案: 真正的密码破解者【难度:2级】--景越Python编程实例训练营,1000道上机题等你来挑战
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了Python练习题答案: 真正的密码破解者【难度:2级】--景越Python编程实例训练营,1000道上机题等你来挑战,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3434字,纯文字阅读大概需要5分钟。
内容图文
![Python练习题答案: 真正的密码破解者【难度:2级】--景越Python编程实例训练营,1000道上机题等你来挑战](/upload/InfoBanner/zyjiaocheng/719/6ab02f5bf9554d699cb1edcbc41d7334.jpg)
真正的密码破解者【难度:2级】:
答案1:
import hashlib
import itertools
def password_cracker(hash):
for length in range(6):
for candidate in map("".join, itertools.product("abcdefghijklmnopqrstuvwxyz", repeat=length)):
if hashlib.sha1(candidate.encode()).hexdigest() == hash:
return candidate?
答案2:
from binascii import unhexlify
from hashlib import sha1
from itertools import product
from string import ascii_lowercase
def password_cracker(hash):
b = unhexlify(hash)
for i in range(6):
for xs in product(ascii_lowercase.encode(), repeat=i):
if sha1(bytes(xs)).digest() == b:
return ''.join(bytes(xs).decode())?
答案3:
import hashlib
import itertools
def password_cracker(hash):
q='abcdefghijklmnopqrstuvwxyz'
for g in range(0,5):
for test in itertools.product(q,repeat=g):
if hashlib.sha1(''.join(test).encode('utf-8')).hexdigest()==hash: return ''.join(test)
for s in q:
for test in itertools.product(q,repeat=4):
if hashlib.sha1((s+''.join(test)).encode('utf-8')).hexdigest()==hash: return s+''.join(test)
?
答案4:
from hashlib import sha1
from itertools import product
from string import ascii_lowercase as alc
hash_gen = ((code, sha1(code.encode()).hexdigest()) for code in (''.join(p) for r in range(6) for p in product(alc, repeat=r)))
rainbow = {}
def password_cracker(hash):
code = rainbow.get(hash, None)
if code is not None:
return code
for code, h in hash_gen:
rainbow[h] = code
if h == hash:
return code?
答案5:
import string
import itertools
import hashlib
def password_cracker(hash):
chars = string.ascii_lowercase
for password_length in range(0, 6):
for guess in itertools.product(chars, repeat=password_length):
guess = ''.join(guess)
result = hashlib.sha1(guess.encode())
if result.hexdigest() == hash:
return guess?
答案6:
import itertools
import string
import hashlib
def password_cracker(hash):
generating = True
minlength = 0
while generating:
for subset in itertools.product(string.ascii_lowercase, repeat=minlength):
word = ''.join(subset)
if hash == gethash(word.encode()):
return word
minlength +=1
if minlength > 5:
generating = False
return ''
def gethash(word):
hash_object = hashlib.sha1(word)
pbHash = hash_object.hexdigest()
return str(pbHash)?
答案7:
import string
import hashlib
from itertools import product
def password_cracker(hash):
alphabet = string.ascii_lowercase
for long in range(6):
cases = product(alphabet, repeat = long)
for case in cases:
temp_hash = hashlib.sha1(''.join(case).encode('utf-8')).hexdigest()
if(hash == temp_hash):
return ''.join(case)?
答案8:
from itertools import product as P
from hashlib import sha1 as S
def password_cracker(h,A='abcdefghijklmnopqrstuvwxyz'):
for i in range(6):
for x in map(''.join,P(A,repeat=i)):
if S(x.encode('ascii')).hexdigest()==h:return x?
答案9:
import hashlib
from itertools import product
from string import ascii_lowercase
def password_cracker(hash):
for n in range(0,6):
all = (''.join(i) for i in product(ascii_lowercase, repeat = n))
for item in all:
hash_object = hashlib.sha1(bytearray(item, 'utf-8'))
check = hash_object.hexdigest()
if check == hash:
return item
break?
答案10:
import hashlib
from itertools import product
from string import ascii_lowercase
def password_cracker(hash):
for n in range(0,6):
all = (''.join(i) for i in product(ascii_lowercase, repeat = n))
for item in all:
hash_object = hashlib.sha1(bytearray(item, 'utf-8'))
check = hash_object.hexdigest()
if check == hash:
return item
break
# return "Password Not Found"
print(password_cracker('e6fb06210fafc02fd7479ddbed2d042cc3a5155e'))?
内容总结
以上是互联网集市为您收集整理的Python练习题答案: 真正的密码破解者【难度:2级】--景越Python编程实例训练营,1000道上机题等你来挑战全部内容,希望文章能够帮你解决Python练习题答案: 真正的密码破解者【难度:2级】--景越Python编程实例训练营,1000道上机题等你来挑战所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。