Go Back   Gaming Gutter > Non-Gaming > Programming > Tutorials


Tutorials - Looking for programming tutorials to increase your knowledge? Do so here.

» Site Navigation
» Home
» FAQ
» Log in
User Name:

Password:

Not a member yet?
Register Now!
» Advertisement
» Recent Threads
Go to first new post S> LEOPETS ACCOUNT. xD
Today 02:10 AM
by *God
Last post by plooshiepoo
Today 07:13 AM
4 Replies, 14 Views
Go to first new post What button do you think...
Today 04:45 AM
by Googlrr
Last post by Googlrr
Today 07:12 AM
4 Replies, 15 Views
Go to first new post Post Your Picture
10-09-2006 11:34 PM
by Ryan
Last post by Premia
Today 07:09 AM
8,019 Replies, 111,779 Views
Go to first new post Jtdusk
10-09-2008 01:32 PM
by Cyrus
Last post by Cyrus
Today 07:08 AM
28 Replies, 319 Views
Go to first new post Contest Discussion Thread
04-09-2008 06:40 PM
Last post by sidespin
Today 07:05 AM
175 Replies, 785 Views
Reply
 
LinkBack Thread Tools Display Modes

 Random Password Generator
Old 10-18-2006, 03:42 PM   #1 (permalink)
Oosband
Guest

 
Posts: n/a
iTrader: / %
Random Password Generator

In this PHP tutorial, I'll show you how to create a script that randomly generates a unique id based on the current time, it's perfect for unique password generation.

Create a page named random_id.php
Add the following:
Code:
<?php
//set the random id length 
$random_id_length = 10; 

//generate a random id encrypt it and store it in $rnd_id 
$rnd_id = crypt(uniqid(rand(),1)); 

//to remove any slashes that might have come 
$rnd_id = strip_tags(stripslashes($rnd_id)); 

//Removing any . or / and reversing the string 
$rnd_id = str_replace(".","",$rnd_id); 
$rnd_id = strrev(str_replace("/","",$rnd_id)); 

//finally I take the first 10 characters from the $rnd_id 
$rnd_id = substr($rnd_id,0,$random_id_length); 

echo "Random Id: $rnd_id"; 
?>
Basically what uniqid does is, it generates a UNIQUE id based on the current time in microseconds and then we use the crypt function to do a one way encryption of the same.
This creates the random password, uniquely.
  Reply With Quote
Reply

Bookmarks



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Random Thoughts wTF ||? Evan General Discussion 5 11-03-2006 05:58 AM
Myth's fact generator thinks i'm a guy. monster Chat 15 10-19-2006 08:34 AM
Password protect a page using php Oosband Tutorials 0 10-18-2006 03:36 PM
Random Question. monster Chat 5 10-03-2006 03:40 PM

Powered by vBadvanced CMPS v3.0 RC2

All times are GMT -7. The time now is 07:16 AM.


vBulletin skin developed by: eXtremepixels
The contents of this webpage are copyright © 2006-2008 GamingGutter.com. All Rights Reserved.

Page generated in 0.12464595 seconds (100.00% PHP - 0% MySQL) with 20 queries