Jump to content


Photo

password


  • Please log in to reply
2 replies to this topic

#1 brown2005

brown2005
  • Members
  • PipPipPip
  • Advanced Member
  • 943 posts

Posted 07 July 2006 - 08:41 AM

Hi,  I want to make it so people have to have a more secure password....

i.e. i want people to use say

cabbage1?

if they have a minimum of 6 characters there password will be level 1, if they add a number it will be level 2 and if they add a character it will be level 3....

any ideas please?

#2 hackerkts

hackerkts
  • Members
  • PipPipPip
  • Advanced Member
  • 593 posts
  • LocationSingapore
  • Age:18

Posted 07 July 2006 - 08:47 AM

What are you trying to do ?
Btw.. You can use strlen to check the lenght of the password.
Also, you can use eregi to check for characters and letters.

Regards,
hackerkts

To be a coder, you must learn how to think and not to give up so easily.


#3 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 07 July 2006 - 10:20 AM

I made an example script for you here:

<?php
/**
 * Check password level script
 * 
 * A script made to demonstrate how password levels could be calculated
 * 
 * @author Daniel Egeberg
 */

/**
 * Password level
 * 
 * A function made to calculate password strength
 *
 * @param string $password The password to check
 * @return integer
 */
function password_level($password)
{
	$level = 0;
	
	if(strlen($password) >= 6)
	{
		$level++;
	}
	
	if(preg_match('/[0-9]/',$password))
	{
		$level++;
	}
	
	return $level;
}

/**
 * Display form
 * 
 * Used to display the form with an optional message
 *
 * @param string $message An optional message
 * @param string $password Used to fill-out the form
 */
function display_form($message=null,$password=null)
{
	$message = !empty($message) ? "<strong>{$message}</strong>\n\n" : null;
	
	echo <<<EOF
{$message}<form action='{$_SERVER['REQUEST_URI']}'>
<label>Password: <input type='text' name='password' value='{$password}' /></label>

<button type='submit'>Calculate password level</button>
</form>
EOF;
}

if(!empty($_GET['password']))
{
	display_form("Your password strength is at level ".password_level($_GET['password']));
}
else {
	display_form();
}
?>

I am not sure what you mean with if it contains characters, so I did not implement that, but I'm sure you can figure out how to do so based on this example script.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users