Author Topic: issues with a password strength meter...  (Read 521 times)

0 Members and 1 Guest are viewing this topic.

Offline MouseTopic starter

  • Enthusiast
  • Posts: 192
  • Gender: Male
  • 127.0.0.1 boy!
    • View Profile
    • After the Mouse
issues with a password strength meter...
« on: August 27, 2006, 07:30:37 AM »
Code: [Select]
<?php
function pwd_strength($pwd)
{
  
$result 0;  # intialize to weakest
  
$result += round(strlen($pwd) / 10);
  foreach(array(
"a-z""A-Z""0-9""^a-zA-Z0-9") as $chars)
  {
    if(
preg_match("/[$chars]/"$pwd))
    {
      
$result += 1;
    }
  }
  return(
min($result6));
}
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang='en'>
<head>
<META HTTP-EQUIV='Content-Type' CONTENT='text/html; charset=ISO-8859-1'>
<title>Password Validation</title>
<style type="text/css">
body {
  font: medium arial, helvetica, sans-serif;
  margin: 0;
  padding: 1em 10%;
}
div {
  height: 20px;
  margin: 5px 0;
  padding: 0;
  border: solid 1px #333;
}
#str0, #str1 {
  width: 12%;
  background-color: #f00;
}
#str2 {
  width: 24%;
  background-color: #c30;
}
#str3 {
  width: 36%;
  background-color: #963;
}
#str4 {
  width: 48%;
  background-color: #693;
}
#str5 {
  width: 60%;
  background-color: #3c0;
}
#str6 {
  width: 72%;
  background-color: #0f0;
}
#rating {
  width: 72%;
  padding: 0;
  margin: 0;
  border: none;
  height: auto;
}
</style>

</head>
<body>
<h1>Password Strength Rating</h1>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<p>Password: <input type="password" name="password" size="16" maxlength="16">
<input type="submit" name="submit" value="Rate Password"></p>
</form>
<?php
if(isset($_POST['submit']))
{
  
$strength pwd_strength($_POST['password']);
  echo 
"<p>Password strength (1 = very weak, 6 = very strong): ".
       
"<strong>$strength</strong></p>\n";
  echo 
"<div id='str$strength'></div>";
  echo 
"<div id='rating'><p style='float: left'>Weak</p>";
  echo 
"<p style='float: right'>Strong</p></div>\n";
}
?>

</body>
</html>
any ideas why i can never get a perfect 6?

Offline litebearer

  • Addict
  • Posts: 2,534
    • View Profile
    • http://nstoia.com
Re: issues with a password strength meter...
« Reply #1 on: August 27, 2006, 08:05:08 AM »
Blame it on the Romanian judge. jk


Lite...
(its ok, I'm Romanian)
Quote
all the brothers were valiant!
The truely intelligent people are not those who create the dots; rather they are they ones with the ability to connect the dots into a coherent picture

Offline onlyican

  • Devotee
  • Posts: 887
  • Gender: Male
  • British bullDog
    • View Profile
    • ClubFeet.net
Re: issues with a password strength meter...
« Reply #2 on: August 27, 2006, 08:17:14 AM »
I dont beleive in Password Strength Meters
I think my password is strongish, as nobody knows it

Some sites says Very Strong
Some sites says Very Weak

All I do to check a password is
Strip Whitespace (from beg and end)
Check its longer than 6 chars (anything less than 6 is just stupid)
make the string lower (THey migh accidently type half the password in caps, so when they log in it wont work)

Store

Thinking about it, One bank I used to use, to log in online, You would need your Passport number, and Pin Code. NOw that aint very secure. (Pins numbers over here in spain and UK are 4 digits)
Tell me the problem, I will try tell you the solution

Offline MouseTopic starter

  • Enthusiast
  • Posts: 192
  • Gender: Male
  • 127.0.0.1 boy!
    • View Profile
    • After the Mouse
Re: issues with a password strength meter...
« Reply #3 on: August 27, 2006, 01:42:27 PM »
but anyways, why wont my meter EVER show a perfect six? following my own rules that the meter was founded on, 6 or more characters, at least one special character and a mix of upper, lower case and didgits... so even #M1ckE4 wont get 6... its got to be a coding bug....

only i don't see it... HELP...

Mouse.

Offline Orio

  • Staff Alumni
  • Addict
  • *
  • Posts: 2,496
  • Gender: Male
    • View Profile
    • OriosRiddle
Re: issues with a password strength meter...
« Reply #4 on: August 27, 2006, 01:49:06 PM »
Try the pass:
"yoyoHI123"
I think it should get a 6.

Orio.
Think you're smarty?

(Gone until 20 to November)