Checking password is strong or weak in swift?

Harpreet
1 min readJul 12, 2021

A strong password is one that can’t be guessed or brute force eaisly. what makes a strong password?to make it not eaisly guessed we can’t make it simple word.strong password should be long and complex (Use the entire keyboard, incorporating numbers, symbols (!£$%^&#@), and both lowercase and uppercase letters).

in the signup page of your app before sending data to server we should always test our password with RegEx( regular expression (shortened as regex or regexp; also referred to as rational expression) is a sequence of characters that specifies a search pattern).

“^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0–9])(?=.*?[#?!@$%^&<>*~:`-]).{8,}$”

RegExDescription

^ The password string will start this way

(?=.*?[a-z]) The string must contain at least 1 lowercase alphabetical character

(?=.*?[A-Z]) The string must contain at least 1 uppercase alphabetical character

(?=.*?[0–9])The string must contain at least 1 numeric character

(?=.*?[#?!@$%^&<>*~:`-])The string must contain at least one special character, but we are escaping reserved RegEx characters to avoid conflict

(?=.{8,})The string must be eight characters or longer

How to use this in swift?

we will use the regex to compare our password and then move forward.

Conclusion:

If you have any queries or questions then you can comment here.

Happy Coding

--

--