import itertools
tsPassWord = "13@dcN" #設置的測試密碼
MaxLenPassword = 10 # 最大密碼長度
wordList="0123abcd@!MN"#密碼字符集合
for lenPassword in range(1,MaxLenPassword+1):
passWd = itertools.product(wordList, repeat =lenPassword) # 調用迭代函數 自匹配
for i in passWd:
str = ''.join(i)
if str == tsPassWord:
print("密碼設置爲",str)
break
展示:
所以爲了我們密碼不那麼容易被破解,
1) 要儘量的長
2)要儘量的包含不同種類的字符