Advertisement
Guest User

Untitled

a guest
Sep 20th, 2018
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.73 KB | None | 0 0
  1. // Password must be 14+ characters long
  2.         if (strlen($plainTextPassword) < 14) {
  3.             $errorSink->addErrorMessage("The password must be 14 or more characters long.");
  4.             $passedCheck = false;
  5.         }
  6.  
  7.         // Password must contain one or more upper-case characters
  8.         if (!preg_match("#[A-Z]+#", $plainTextPassword)) {
  9.             $errorSink->addErrorMessage("The password must contain at least one upper-case letter.");
  10.             $passedCheck = false;
  11.         }
  12.  
  13.         // Password must contain one or more lower-case characters
  14.         if (!preg_match("#[a-z]+#", $plainTextPassword)) {
  15.             $errorSink->addErrorMessage("The password must contain at least one lower-case letter.");
  16.             $passedCheck = false;
  17.         }
  18.  
  19.         // Password must contain one or more digits
  20.         if (!preg_match("#[0-9]+#", $plainTextPassword)) {
  21.             $errorSink->addErrorMessage("The password must contain at least one digit.");
  22.             $passedCheck = false;
  23.         }
  24.  
  25.         // Must contain at least one special (non-word) character
  26.         if (!preg_match("#\W+#", $plainTextPassword)) {
  27.             $errorSink->addErrorMessage("The password must contain at least special character. You may not use the following characters: ' \" ( ) ; - | < >");
  28.             $passedCheck = false;
  29.         }
  30.  
  31.         // Must NOT contain any of the following characters.
  32.         if (preg_match("#'\"();-|<>#", $plainTextPassword)) {
  33.             $errorSink->addErrorMessage("The password must not contain any of the following characters: ' \" ( ) ; - | < >");
  34.             $passedCheck = false;
  35.         }
  36.  
  37.         // Must NOT contain more than 2 sequential numbers.
  38.         if (preg_match("#012|123|234|345|456|567|678|789|890#", $plainTextPassword)) {
  39.             $errorSink->addErrorMessage("The password must not contain more than two sequential numbers. For example, 12 is allowed, 123 is not.");
  40.             $passedCheck = false;
  41.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement