Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Password must be 14+ characters long
- if (strlen($plainTextPassword) < 14) {
- $errorSink->addErrorMessage("The password must be 14 or more characters long.");
- $passedCheck = false;
- }
- // Password must contain one or more upper-case characters
- if (!preg_match("#[A-Z]+#", $plainTextPassword)) {
- $errorSink->addErrorMessage("The password must contain at least one upper-case letter.");
- $passedCheck = false;
- }
- // Password must contain one or more lower-case characters
- if (!preg_match("#[a-z]+#", $plainTextPassword)) {
- $errorSink->addErrorMessage("The password must contain at least one lower-case letter.");
- $passedCheck = false;
- }
- // Password must contain one or more digits
- if (!preg_match("#[0-9]+#", $plainTextPassword)) {
- $errorSink->addErrorMessage("The password must contain at least one digit.");
- $passedCheck = false;
- }
- // Must contain at least one special (non-word) character
- if (!preg_match("#\W+#", $plainTextPassword)) {
- $errorSink->addErrorMessage("The password must contain at least special character. You may not use the following characters: ' \" ( ) ; - | < >");
- $passedCheck = false;
- }
- // Must NOT contain any of the following characters.
- if (preg_match("#'\"();-|<>#", $plainTextPassword)) {
- $errorSink->addErrorMessage("The password must not contain any of the following characters: ' \" ( ) ; - | < >");
- $passedCheck = false;
- }
- // Must NOT contain more than 2 sequential numbers.
- if (preg_match("#012|123|234|345|456|567|678|789|890#", $plainTextPassword)) {
- $errorSink->addErrorMessage("The password must not contain more than two sequential numbers. For example, 12 is allowed, 123 is not.");
- $passedCheck = false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement