我正在读这篇thread,它启发我研究如何优化简单生成密码的暴力强制。你知道吗
我试图从key=''.join(random.sample(string.uppercase, 7))
迭代所有可用的密码组合。如果我读对了文档:key
在本例中,不能由两个相似或相等的字母组成。它始终是(在本例中)唯一的7长大写字符串。你知道吗
str(key)
无法生成:AARGHJU
如何更改while语句,使其不迭代包含类似字母的字符串?你知道吗
chars = 'ABCDEFGHIJKLMNOPQRSTUVXYZ' # chars to look for
try:
while 1:
# Iteration processess of possibel keys
for length in range(7,8): # only do length of 7
to_attempt = product(chars, repeat=length)
for attempt in to_attempt:
print(''.join(attempt))
except KeyboardInterrupt:
print "Keybord interrupt, exiting gracefully anyway."
sys.exit()
产生ex将产生不必要的时间和功率:
AAAFXEL
AAAFXEM
AAAFXEN
AAAFXEO
AAAFXEP
AAAFXEQ
AAAFXER
AAAFXES
对于整个空间的非重复枚举,可能需要itertools.排列. 你知道吗
相关问题 更多 >
编程相关推荐