Home Techindex PHP Simple password generator

 
 

PHP Simple password generator
Posted on: April 14, 2006 at 12:00 AM
Advertisement
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
 
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
 
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 encryption in php - PHP
password encryption in php  example of password encryption in php
 
simple class in php
simple class in php  example of simple class in PHP
 
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
 
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
 
Hibernate generator Element
; type="long" column="Id" > <generator class="assigned"/> </id> A simple interface..., short or int. assigned This generator lets to assign an identifier
 
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
 
Softabar Password Manager
. Customizable password generator for automatic password generation. Automatic updates... Softabar Password Manager       Softabar Password Manager is an easy way to manage
 
Generator Tag (Control Tags) Example
Generator Tag (Control Tags) Example       In this section, we are going to describe the generator tag. The generator tag...; } } Create a jsp page where the generator tag
 
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="
 
PHP
, it is then processed by the PHP engine and dynamic output id generator... Generate PDF files with the PHP PDF libraries Writing a simple PHP program... it by typing the url of the page into web browser. Here is the simple example of PHP
 
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
 
Generator in Hibernate
Generator in Hibernate  What is the generator in hibernate
 
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
 
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
 
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
 
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
 
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
 
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
 
sql php array
sql php array       SQL PHP Array support simple dimension array. The SQL PHP Array is used... illustrate an example from 'SQL PHP Array'. To understand and grasp
 
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
 
Hibernate Generator
This tutorial is helpful in understanding the concept of hibernate generator
 
create a simple form
create a simple form  Helo. i am learning php, and i need help creating below for. Its simple but i need help. Create a form that contains: 1. Name, textbox 2. Submit button If the user inputs the Name textbox and clicks
 
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
 
$_get php example - PHP
$_get php example  Explain the $_get method in php with a simple example. m a beginner
 
Java Password Field
Java Password Field In this section we will discuss how to use password field in Java. To create a password field in Java Swing JPasswordField is used... of text field which allows to enter password only. Due to the security reason
 
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
 
hibernate metamodel generator
In this section, you will learn about hibernate metamodel generator
 
simple code for XML database in JS
simple code for XML database in JS  Sir , i want a code in javascript for XML database to store details (username and password entered by user during registration process (login process)). please send me a code . Thank you
 
New features in PHP 5.5
available in PHP 5.5 Here is the syntax of using the the password hashing API... the password using following code: password_verify($password, $hash); 4. In PHP 5.5... Starting PHP Learn the basics of PHP with this quick and simple tutorial
 
Sequence generator problem - JDBC
Sequence generator problem  Dear sir, I have created one table by name massemailsendingdetails. CREATE TABLE MASSEMAILDETAILS( ID...) ); Then i created a sequence generator for an id as follows CREATE SEQUENCE
 
Generator Tag
; } } Create a jsp page where the generator tag...;  Output of the  Generator Tag Example
 
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 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? It is an open source scripting language which can
 
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 define variable
php define variable  How to define a simple and a global variable in PHP
 
Understanding Hibernate element
about hibernate <generator> method in detail. Hibernate generator element... by the generator method to be used in different situations. The <generator> element... to pass the parameter (s) to the  class. Here is the example of generator
 
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 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
 
org.hibernate.MappingException: could not instantiate id generator
" org.hibernate.MappingException: could not instantiate id generator
 
org.hibernate.MappingException: could not instantiate id generator
" org.hibernate.MappingException: could not instantiate id generator
 
org.hibernate.MappingException: could not instantiate id generator
" org.hibernate.MappingException: could not instantiate id generator
 
org.hibernate.MappingException: could not instantiate id generator
" org.hibernate.MappingException: could not instantiate id generator
 
forgot password?
forgot password?  forgot password
 
Advertisement

Related Tags for PHP Simple password generator:


Advertisements Advertisements
 

 

 

DMCA.com