WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : A few functions to create random passwords.
Categories : PHP, Security, Strings
Boaz Yahav
Date : Mar 23rd 2003
Grade : 3 of 5 (graded 12 times)
Viewed : 9998
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Boaz Yahav
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

If you want to generate a random password for any use you can use this function :

<?
function gen_password($length = 8) {
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
for($i = 0; $i < $length; $i++) {
$x = rand(0, strlen($chars) -1);
$password .= $chars{$x};
}
return $password;
}
?>

You may want to leave out a few problematic characters so that the people receiving the passwords
don't mix them like :

- 1 (number one)
- l (lower-case letter L)
- I (upper-case letter I)
- 0 (number zero)
- O (upper-case letter O)

so you get :
<?
function gen_password($length = 8) {
$chars = "abcdefghijkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
for($i = 0; $i < $length; $i++) {
$x = rand(0, strlen($chars) -1);
$password .= $chars{$x};
}
return $password;
}
?>

A different approach may be using md5 to generate a random string and take a part of it :

<?
//This function is limited to a 32 char long pass but
//this does not seem to be a real problem :)
function gen_password($length = 8) {
srand((double)microtime()*1000000);
$UniqID=md5(uniqid(rand()));
$password=substr(md5(uniqid(rand())),0,$length);
return $password;
}
?>



Function to generate readable/remeberable random password
Categories : PHP, Security, Security
Random Password Generator
Categories : PHP, Strings, Security
A damaged image generator (class) for validating text. CAPTCHA - Completely Automated Public Turing test to tell Computers and Humans Apart
Categories : PHP, PHP Classes, Security, GD image library, Security
Use of bitmasks to represent permissions
Categories : PHP, Authentication, Bitwise Operators, Security, PHP Classes
complete simply working javascript password generator file. Use letter, vowels, consonants (uppercase and lowercase) arrays to create a really random and secure password. improved security using time functions to initialize random number generator.
Categories : Java Script, HTML, Security, Authentication, Strings
Simple Email address validation
Categories : Email, PHP, Strings
mysql_escape_string
Categories : PHP, MySQL, Databases, Strings
SHA: Implementation of the Secure Hash Algorithm in pure PHP. This is a secure one-way function that can be used to perform challenge response login algorithms over an insecure connection.
Categories : Algorithms, PHP, Security
Look for the *position* of the first occurence of string2 in string1, beginning at position start.
Categories : Complete Programs, PHP, Strings
How to Get a character array from a string
Categories : PHP, Strings, Arrays
Easily Grant Temporary SSH Access to yourself when in remote location
Categories : PHP, Linux, Cron, Security
Simple Password example
Categories : PHP, Authentication, Security, HTTP
Printer friendly pages from anywhere on a website.
Categories : PHP, Strings, Content Management
Query2Report : Generating Html, Pdf and Csv Reports from SQL Query
Categories : PHP, PHP, HTML, PDF, Excel
function textwrap will wrap text to any desired width using <BR>\n as the default line break. Default wrap width is 80 columns.
Categories : Strings, HTML and PHP, PHP