As mentioned in this Meta Question , Facebook accepts the exact opposite of our password. For instance:
1.- paSSw5ORD (Original password) 2.- PAssW5ord (Case altered to exact opposite, Capital->Small and vice-versa.) 3.- PaSSw5ORD (Only first letter case altered)
How to get the second option, if the first one is original, entered by the user (or the first when the user enters the second version)? Here is my example.
<?php $pass = "paSSw5ORD"; //Example password $pass_len = strlen($pass); //Find the length of string for($i=0;$i<$pass_len;$i++){ if(!(is_numeric($pass[$i]))){ //If Not Number if($pass[$i]===(strtoupper($pass[$i]))){ //If Uppercase $pass2 .= strtolower($pass[$i]); //Make Lowercase & Append } else{ // If Lowercase $pass2 .= strtoupper($pass[$i]); //Make Uppercase & Append } } else{ //If Number $pass2 .= $pass[$i]; //Simply Append } } //Test both echo $pass."\r\n"; echo $pass2; ?>
But how to make it handle passwords with special characters (is everything possible on a standard English keyboard?
!@
This does not work with all special characters.
if(preg_match('/^\[a-zA-Z]+$/', "passWORD")){ //Special Character encountered. Just append it and //move to next cycle of loop, similar to when we //encountered a number in above code. }
I'm not a RegEx expert, so how do I modify the above RegEx to make sure that it handles all the above special characters?
source share