2016-09-15 37 views
1

例如,密碼可能具有以下所述的序列。 qwer,1234,1qaz,qwe,qaz,qwer, asd,asdf,wsx,wsx,2wsx,wer,asdf,1234,zxcv,5678。請問我寫一個簡單的python代碼來查看給出的密碼是否包含上述提到的序列python代碼來確定密碼是否包含序列

+0

看到這裏http://stackoverflow.com/help/mcve如何提問。 – Guenther

+0

Check out https://stackoverflow.com/questions/34582576/checking-a-string-for-adjacent-characters-on-the-keyboard – TimSC

回答

0

您可以迭代並測試密碼中是否有文本。例如:

bad_strings = ["qwer", "1234", "1qaz", "qwe", "qaz", "qwer"] 
passwords = ["blah347", "password1", "password2", "badqwer", "badqaz"] 

def check_for_bad_password(password): 
    for bad_string in bad_strings: 
     if bad_string in password: 
      return password 

for password in passwords: 
    if check_for_bad_password(password): 
     print(password) 

此打印出badqwerbadqaz

相關問題