Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regex password checker

I am creating some regex code so I can check passwords when a customer is trying to create a account. Currently I have two pieces of code that seem to work when tested on :- http://www.regexplanet.com/simple/index.html.

The first bit is:

^.*(?=.{8,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=]).*$

This makes sure:

  • Password is 8 digits long
  • Contains at least one one lower case letter, one upper case letter, one digit and one special character

The second part is:

\S*(.)\1{3,}\S*

This makes sure:

Any 4 or more consecutive identical characters are matched.

The question is, how can I combine them both? I have tried to no avail but they seem to be working fine seperatly.

Thanks

like image 281
Sad Avatar asked Dec 21 '25 14:12

Sad


1 Answers

You might want to considering allowing passwords greater then at least 12 characters. Do yourself a favor and your customer's a favor and allow a customer to use any size password greater then 12 characters. Anything less then 12 is extremely easy to brute foce.

As to your question I will let somebody else answer that.

like image 110
Security Hound Avatar answered Dec 24 '25 03:12

Security Hound



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!