The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Strong Password V2
#1
I share the code for calculate the strong of one password

<pre>
Code:
entropia_x_caracter= log2(n)

entropia_password= longitud * entropia_x_caracter
</pre>


<pre>
Code:
function checkPass($pass) {
     $count=strlen($pass);
     $entropia=0;
    // Si el password tiene menos de 6 caracteres
    if ($count < 6) {
         return 'El password es muy corto.';
    }
  
    // Contamos cuantas mayusculas, minusculas, numeros y simbolos existen
    $upper = 0; $lower = 0; $numeros = 0; $otros = 0;
    
    for ($i = 0, $j = strlen($pass); $i < $j; $i++) {
        $c = substr($pass,$i,1);
        if (preg_match('/^[[:upper:]]$/',$c)) {
            $upper++;
        } elseif (preg_match('/^[[:lower:]]$/',$c)) {
            $lower++;
        } elseif (preg_match('/^[[:digit:]]$/',$c)) {
            $numeros++;
        } else {
            $otros++;
        }
    }

   // Calculamos la entropia
  
  $entropia= ($upper*4.7)+ ($lower*4.7)+($numeros*3.32)+($otros*6.55);
  
  if ($entropia<28)
  {
    echo "Password muy debil";    
   }elseif($entropia<36) {
        echo "Password debil";            
   }elseif($entropia<60) {
       echo "Password Razonable";
   }elseif($entropia<128) {
       echo "Password Fuerte";
   }else {
       echo "Password Muy Fuerte";
       }
    
    return false;
    
}
echo checkPass("CAPautomovil-2012");

?>
</pre>

  Reply
#2
This has been on my mental to-do list for a while! Thank you. I will check this out!
  Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)