2

I'm trying to code a password strength checker, and I want to deduct points if the entered password is a common keyboard combination such as "qwerty" or "asdfg". I have a list that goes ['q', 'w', 'e', ... 'b', 'n', 'm']. If any part of the input has consecutive elements from the list, I want to deduct points. Say the password is "djoDFGibTY" (Caps just to highlight, all lower case), I want my code to catch the "DFG" and "TY" and deduct points twice, with more points deducted in the first case for a triple violation and lesser in the second case for a double violation. Thank You.

keyboard_pattern = ['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'z', 'x', 'c', 'v', 'b', 'n', 'm']

if password in keyboard_pattern:

score -= 15
5
  • meta.stackoverflow.com/a/251362/476 Commented Jun 19, 2019 at 11:28
  • with more points deducted in the first case for a triple violation and lesser in the second case for a double violation, how many points for the first case and how many for the second case Commented Jun 19, 2019 at 11:30
  • Lets say for two consecutive characters, I want a -5; for three consecutive characters a -7; and so on. Commented Jun 19, 2019 at 11:32
  • codereview.stackexchange.com/questions/177415/… Does this answer what you're after? Commented Jun 19, 2019 at 11:39
  • This doesn't take care of 2 consecutive or 4 consecutive chars, but just for 3 consecutive characters Commented Jun 19, 2019 at 12:09

1 Answer 1

2

As found on https://codereview.stackexchange.com/questions/177415/python-qwerty-keyboard-checker

input = input("What is your password?")
qwerty = 'qwertyuiopasdfghjklzxcvbnm'
lower = input.lower()
for idx in range(0, len(lower) - 2):
    test_seq = lower[idx:idx + 3]
    if test_seq in qwerty:
        points -= 5
print(points)
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.