PHP Password Generator Class

Secure, powerful and random password generator class is a need of every developer, administrator, blogger and the user of every level. Chip Password Generator class will be helpful to generate passwords with random and fixed length strings.

PHP password generator is a complete, working random password generation class written in PHP. It allows the developer to customize the password by upper letters, lower letters, numbers, symbols, length and strength.

Features

  • Generate random password by using 4 inputs i.e Alpha Upper (A-Z), Alpha Lower (a-z), Number (0-9) and Special symbols
  • You have flexible power to choose desired length for random passwords
  • Complete control ( Switch On or Off ) over 4 basic inputs to generate passwords of different strengths
  • Class uses built-in PHP features to generate password with speed and accuracy
  • Class will generate random password by taking the entry of every selected input instead of general randomization
  • Class will produce a powerful and secure password by avoiding repetition of selected input

Requirements

  • PHP5 or higher

Download archive contains a full demo to use this class. I am also going to write a comprehensive tutorial online that will assist you – how to use Chip Password Generator class.

Include “class.chip_password_generator.php”

You have to include Chip Password Generator class at top of page or a suitable location according to your logic.

require_once("class.chip_password_generator.php");

Array: $args

  • length (integer): This parameter will help you to choose the length of password.
  • alpha_upper_include (boolean TRUE | False): You have option to include/exclude upper letters (A-Z) for generating a simple random password.
  • alpha_lower_include (boolean TRUE | False): You have option to include/exclude lower letters (a-z) for generating a password of medium strength.
  • number_include (boolean TRUE | False): You have option to include/exclude numbers (0-9) for generating the strong password.
  • symbol_include (boolean TRUE | False): You have option to include/exclude special symbols for generating a powerful password that will be very hard to guess.

Class Instance

You have studied $args parameters to use this class according to your wish and idea. Let’s have a look into class instantiation.

 $args = array(
	'length'				=>	8,
	'alpha_upper_include'	=>	TRUE,
	'alpha_lower_include'	=>	TRUE,
	'number_include'		=>	TRUE,
	'symbol_include'		=>	TRUE,
	);
$object = new chip_password_generator( $args );

These are default parameters of $args. You can skip to write these, if you wish to use class with default parameters. So you can also instantiate class without passing any argument,

$object = new chip_password_generator();

Generate Password

It is time to generate password after this short learning and tutorial about this class. You can generate password by using following method,

$password = $object->get_password();

Cool, you are successful to generate passwords for your projects, codes and algorithms.

Complete Tutorial – At a Glance

/*
|-----------------
| Chip Download Class
|------------------
*/

require_once("class.chip_password_generator.php");

/*
|-----------------
| Class Instance
|------------------
*/

$args = array(
	'length'				=>	8,
	'alpha_upper_include'	=>	TRUE,
	'alpha_lower_include'	=>	TRUE,
	'number_include'		=>	TRUE,
	'symbol_include'		=>	TRUE,
	);
$object = new chip_password_generator( $args );

/*
|-----------------
| Generate Password
|------------------
*/

$password = $object->get_password();

echo $password;

Screenshot

Online Demo

I have developed online demo of this password generator class. I hope you will enjoy.

License – GPLv2

This class has been distributed under GPLv2.

Download Package: 1.2 – 3.58 Kb

Click here to download complete package of Chip Password Generator class (version 1.2). Package contains,

  • class.chip_password_generator – Main Class
  • index.php – Demos home page
  • style.css – Minimal style

Download Package: 1.0 – 3.36 Kb

Click here to download complete package of Chip Password Generator class (version 1.0).

1.2

Class is updated on December 23, 2010.

  • A change in algorithm to include character of every selected input to generate random password instead of general randomization
  • Avoid repetition of characters of selected input while generating secure and powerful password

1.0

Class is released on December 02, 2010.

  • This is the first version of PHP password generator class.