PHP Simple password generator
Posted on: April 14, 2006 at 12:00 AM
The simplest password generator described here uses one cycle to concatenate random characters into the random sized string.

PHP Simple password generator

In this tutorial I will be showing you how to create a random password using nothing but loops and random letters. For extra security I will define a minimum length and a maximum length, I will also make it so you can't define a password from using the url.

First we need to define everything. This includes the min length, max length and emptying the password:

$min=4;
$max=15;
$pwd="";


Now we need to start the loop of creating it, using the $min and $max we can get a random length:

for($i=0;$i<rand($min,$max);$i++)

We need to get a load of letters now, but we have to be sure there are valid letters and not other characters:

$num=rand(48,122);
if(($num > 97 && $num < 122))
{
    $pwd.=chr($num);
}

else if(($num > 65 && $num < 90))
{
    $pwd.=chr($num);
}

else if(($num >48 && $num < 57))
{
    $pwd.=chr($num);
}

else if($num==95)
{
    $pwd.=chr($num);
}

Just a load of checking, nothing much really there. Because this is a tutorial, we would output the result of our password:

echo $pwd;

Be carefull about including that line for the final script. If you are emailing the password then you don't need it, you decide.

The complete code is here:

<?php
// filename "pword.php"


$min=4; // minimum length of password
$max=15; // maximum length of password
$pwd=""; // to store generated password

for($i=0;$i<rand($min,$max);$i++)
{
$num=rand(48,122);

  if(($num > 97 && $num < 122))
  {
      $pwd.=chr($num);
  }

  else if(($num > 65 && $num < 90))
  {
      $pwd.=chr($num);
  }

  else if(($num >48 && $num < 57))
  {
      $pwd.=chr($num);
  }

  else if($num==95)
  {
      $pwd.=chr($num);
  }

  else
  {
      $i--;
  }
}

echo $pwd; // prints the password
?>


More Tutorials on roseindia.net for the topic PHP Simple password generator.
PHP Simple password generator
PHP Simple password generator In this tutorial I will be showing you how to create a random password using nothing but loops and random letters. For extra... make it so you can't define a password from using the url. First we need
 
ModuleNotFoundError: No module named 'simple_password_generator'
ModuleNotFoundError: No module named 'simple_password_generator'  Hi...: No module named 'simple_password_generator' How to remove the ModuleNotFoundError: No module named 'simple_password_generator' error? Thanks  
 
password encryption in php - PHP
password encryption in php  example of password encryption in php
 
ModuleNotFoundError: No module named 'password-generator'
ModuleNotFoundError: No module named 'password-generator'  Hi, My... named 'password-generator' How to remove the ModuleNotFoundError: No module named 'password-generator' error? Thanks   Hi, In your
 
encrypt the username and password using PHP
encrypt the username and password using PHP  How can we encrypt the username and password using PHP?   Hi friends, You can use the MySQL PASSWORD() function to encrypt username and password. For example, INSERT
 
ModuleNotFoundError: No module named 'python-password-generator'
ModuleNotFoundError: No module named 'python-password-generator'  Hi...: No module named 'python-password-generator' How to remove the ModuleNotFoundError: No module named 'python-password-generator' error? Thanks  
 
ModuleNotFoundError: No module named 'random-password-generator'
ModuleNotFoundError: No module named 'random-password-generator'  Hi...: No module named 'random-password-generator' How to remove the ModuleNotFoundError: No module named 'random-password-generator' error? Thanks  
 
ModuleNotFoundError: No module named 'ca-password-generator'
ModuleNotFoundError: No module named 'ca-password-generator'  Hi...: No module named 'ca-password-generator' How to remove the ModuleNotFoundError: No module named 'ca-password-generator' error? Thanks   Hi
 
ModuleNotFoundError: No module named 'password-generator-gtk'
ModuleNotFoundError: No module named 'password-generator-gtk'  Hi...: No module named 'password-generator-gtk' How to remove the ModuleNotFoundError: No module named 'password-generator-gtk' error? Thanks   Hi
 
ModuleNotFoundError: No module named 'python-password-generator'
ModuleNotFoundError: No module named 'python-password-generator'  Hi...: No module named 'python-password-generator' How to remove the ModuleNotFoundError: No module named 'python-password-generator' error? Thanks  
 
ModuleNotFoundError: No module named 'random-password-generator-cli'
ModuleNotFoundError: No module named 'random-password-generator-cli'  ...: No module named 'random-password-generator-cli' How to remove the ModuleNotFoundError: No module named 'random-password-generator-cli' error
 
ModuleNotFoundError: No module named 'ca-password-generator'
ModuleNotFoundError: No module named 'ca-password-generator'  Hi...: No module named 'ca-password-generator' How to remove the ModuleNotFoundError: No module named 'ca-password-generator' error? Thanks   Hi
 
PHP
generator to the users. History of PHP Rasmus Lerdof created a language... files with the PHP PDF libraries Writing a simple PHP program You can embedded... of the page into web browser. Here is the simple example of PHP that prints "
 
simple class in php
simple class in php  example of simple class in PHP
 
forget password?
forget password?  can anyone help me? how to create a module of forget password?the password can reset by generate random password and send to user's email..i develop the php system using xampp and dreamweaver
 
forget password?
forget password?  can anyone help me? how to create a module of forget password?the password can reset by generate random password and send to user's email..i develop the php system using xampp and dreamweaver
 
php
Write a simple PHP program that display the days of week as per the system date using switch case statement.  Write a simple PHP program that display the days of week as per the system date using switch case statement
 
php
php  im beginner to php. i faced problem with creating form and data stored into mysql <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01...; <td><input type="Password" name="pwd" size="20">
 
php
php  im beginner to php. i faced problem with creating form and data stored into mysql <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01...; <td><input type="Password" name="pwd" size="20">
 
PHP
is valid and uses the correct password. If the user is not in the database, then the user should be prompted to register the username and password, and then allowed to use the username and the password to access the system (Main Menu
 
Simple Java applet that need usernam, password and textfield.
Simple Java applet that need usernam, password and textfield.  Hi. Anyone can help me on this matter: I need to create a small application that require user to login by username and password. After login, they should meet
 
How can we encrypt the username and password using PHP?
How can we encrypt the username and password using PHP?  How can we encrypt the username and password using PHP
 
PHP User Authentication Login and password check Tutorial
Creating a click counter is pretty simple. All it requires is after the code has been trigger, to add 1 to the given row. Sound easy enough? The fields... to the database. $dbname="name"; #Password to verify its you. $dbpass="
 
ModuleNotFoundError: No module named 'simple_test_generator'
ModuleNotFoundError: No module named 'simple_test_generator'  Hi...: No module named 'simple_test_generator' How to remove the ModuleNotFoundError: No module named 'simple_test_generator' error? Thanks   Hi
 
Softabar Password Manager
. Customizable password generator for automatic password generation. Automatic updates... Softabar Password Manager       Softabar Password Manager is an easy way to manage
 
sql php array
sql php array       SQL PHP Array support simple dimension array. The SQL PHP Array is used... The Tutorial illustrate an example from 'SQL PHP Array'. To understand
 
PHP Registering simple statistics
PHP Registering simple statistics Have you ever wanted to know who visited... ! In this tutorial I will teach you how to make a simple PHP Script that writes... that they visited ! This program follows a simple algorithm as follows: 1. Grab
 
Data Generator
JavaScript, PHP and MySQL. Characteristics Data generator is browser... Data Generator Data Generator is free open source script that is designed to create the application, which can be used to generate a large sum of data
 
$_get php example - PHP
$_get php example  Explain the $_get method in php with a simple example. m a beginner
 
change password - JSP-Servlet
a simple web application using mysql and jsp. now i want to create a web page for a user. this web page consists of changing the password for the existing user. it look like this: current password new password confirm new password SUBMIT
 
New features in PHP 5.5
;; } 3. The new password hashing API is now available in PHP 5.5ADS_TO_REPLACE_4... following code:ADS_TO_REPLACE_5 password_verify($password, $hash); 4. In PHP 5.5...New features in PHP 5.5 - The latest version of PHP version 5.5 provides many
 
calendar in php code - PHP
calendar in php code   Any Idea to create a calendar for school in PHP? I need a simple nd handy code
 
random pass generator - Java Beginners
"NamePass") that will generate a list of 20 passwords. Each password is to contain... a list of 20 names (or create one yourself with a simple text editor). Store... and associated password, both to the screen and to a newly created data file called
 
Password - Java Beginners
charecter just as typing password in E-mail.ID without using applet... can we do that??.. if so halp me...  Hi friend, I am sending you simple code... = Box.createHorizontalBox(); rowTwo.add(new JLabel("Password")); rowTwo.add(new
 
Password
Password  make a program which ask ask the username and password * in this format. in C language
 
Session management in php - PHP
Session management in php  I am creating a simple program in PHP to manage the session of user. It's basically a simple form that will allow a user to fill & submit the offer form after login. Please Explain me how can i create
 
PHP
PHP Services PHP refers to Hypertext Preprocessor, a general... scripting language. PHP generally runs on web server. It is competent..., Linux, Mac Os, Sun Solaris and others. But for processing the PHP code
 
PHP MySQL Connect to a Database
' (using password: NO) in C:\wamp\www\php\dbConn.php on line 2 error NOTE... PHP MySQL Connect to a Database:       In WAMP software stack, php and mysql are bundled together and we can use
 
php java
php java  why PHP is becoming more popular than java   PHP is more popular than Java because of following reasons: 1)PHP web hosting options are superior. 2)PHP provides rapid development and instant gratification
 
PHP Question
PHP Question  I am trying to make php Readline where it reads from.... { > fclose($handle); // Close the file. } > $password=readLine("/home/users/".$username.".txt", > 1); if ($password==$_POST['oldpass']) >
 
PHP Question
PHP Question  I am trying to make php Readline where it reads from.... { > fclose($handle); // Close the file. } > $password=readLine("/home/users/".$username.".txt", > 1); if ($password==$_POST['oldpass']) >
 
PHP Getting Started With PHP Tutorial
PHP Getting Started       Learn the basics of PHP with this quick and simple tutorial. Designed for the very beginners. What is PHP?ADS_TO_REPLACE_1 It is an open source scripting
 
PHP Functions, PHP Functions Tutorials
PHP Functions In this section we will understand important PHP functions... or not by passing  username and password as parameter. In the function declaration you...,$password) { $isValidUser=false; //Write code to connect
 
simple eg
simple eg   <?php</li> $string = ?Hello Users?; print (?Welcome to Roseindia, I want to greet $string?); print (??); $string = ?Bye Bye!?; print (?OK meet you soon, $string?); ?> in this program we get a error at line
 
simple code to write an read and write the login detail to a xml file using javascript ( username and password )
simple code to write an read and write the login detail to a xml file using javascript ( username and password )  pls can nyone give me a code to write and read the login details (username and password )into a xml file using
 
HTTP Authentication With PHP
variables. Instead of using simple PHP_AUTH_USER and PHP_AUTH_PW, it's may...HTTP Authentication with PHP: The HTTP Authentication is available when... which contains the PHP script is again called with the predefined variables
 
PHP Examples
In this section of PHP examples, the new bees will learn the basic examples... as assesing our codes, the programmers can develop simple to very complex programs. In this PHP example section, we have tried to cover the whole range of PHP
 
Javascript and PHP
Javascript and PHP  Hello, I want to know how to call javascript function inside PHP code . Could you please tell me the way to call it? Thanks   Here is a simple example of php that calls javascript function. <
 
php define variable
php define variable  How to define a simple and a global variable in PHP
 
Send forgot Password through mail - JSP-Servlet
Send forgot Password through mail   hello every one I am designing a admin login page where i am validating the password through file(Example if user Name is Sreenivas and types sree as password i check a file where i
 
Ads

Related Tags for PHP Simple password generator:


Ads

 
Advertisement null

Ads