using regex for password validation

Chris Angelico rosuav at gmail.com
Wed Dec 23 17:03:53 EST 2020


On Thu, Dec 24, 2020 at 4:09 AM Sadaka Technology
<sersadaka1 at outlook.com> wrote:
>
> hello guys,
>
> I have this pattern for password validation (regex):
>
> I want these rules to be applied:
>
> Minimum 8 characters.
> The alphabets must be between [a-z]
> At least one alphabet should be of Upper Case [A-Z]
> At least 1 number or digit between [0-9].
> At least 1 character from [ _ or @ or $ ].
>
> and this pattern:
>
> passwordpattern = "^(?=.[a-z])(?=.[A-Z])(?=.\d)(?=.[@$])[A-Za-z\d@$!%?&]{8,}.$"
>
> my only issue is that I want to add the symbol () and symbol(.) in the pattern where only it accepts $ and @, I tried adding generally like [@_$] not working
>

Easy solution:

passwordpattern = ".{11,}"

This mandates more security than the one you're using, AND it's far
less frustrating for users.

Please stop inflicting horrific password rules on the world.
Especially, requiring one "symbol" - where "symbol" is always defined
differently from one place to another (and in your case, you're
offering just three valid options) - causes weaker passwords and more
frustration.

Just don't do it.

ChrisA


More information about the Python-list mailing list