 |
| ::: T4VN Statistics ::: |
PHP Scripts : 64 |
PHP Example : 67 |
PHP Tutorials : 21 |
PHP News : 93 |
Total Coupon : 36 |
Other Tutorials : |
Member : 215 |
Visitor Online : 2 |
Today Visit: 128 |
Total Visitor : 285994 |
Most Online : 41 |
|
 |
 |
PwdGen
Author : Zapotek
A simple, pesudo-random, password generator written in PHP ( Command Line Interface ).
| PHP Example : | | #!/usr/bin/php
<?php
/********************************************************************
* Author Info
* -----------
* Author: Zapotek
* E-Mail: zapmade[at]gmail.com
*
* File Info
* ---------
* Name: PwdGen
* IDE Used: Eclipse IDE using the PHPEclipse Plug-In
* OS Used: Novell SuSE Linux 10
* Tested Under: PHP 4.3.11 (cgi)
*
* Comments
* --------
* Just a:
* Pseudo-Random Password Generator
********************************************************************/
//Declaring vars
$num_s = 48;
$num_e = 57;
$high_letter_s = 65;
$high_letter_e = 90;
$low_letter_s = 97;
$low_letter_e = 122;
$all_s = 33;
$all_e = 126;
$char_type = $argv[2];
$len = $argv[1];
if ($argc < 3) {
echo "Usage: $argv[0] <length> <type>\n\n".
"Types:\n"."-num\tNumerical\n".
"-ll\tLower letters\n".
"-hl\tHigher letters\n".
"-e\tEverything goes\n";
}
switch ($argv[2]) {
case "-num";
for ($i = 0; $i < $len; $i ++) {
$out = rand($num_s, $num_e);
$pwd .= sprintf("%c", $out);
}
echo $pwd;
info($num_s, $num_e, $len);
break;
case "-ll";
for ($i = 0; $i < $len; $i ++) {
$out = rand($low_letter_s, $low_letter_e);
$pwd .= sprintf("%c", $out);
}
echo $pwd;
info($low_letter_s, $low_letter_e, $len);
break;
case "-hl";
for ($i = 0; $i < $len; $i ++) {
$out = rand($high_letter_s, $high_letter_e);
$pwd .= sprintf("%c", $out);
}
echo $pwd;
info($high_letter_s, $high_letter_e, $len);
break;
case "-e";
for ($i = 0; $i < $len; $i ++) {
$out = rand($all_s, $all_e);
$pwd .= sprintf("%c", $out);
}
echo $pwd;
info($all_s, $all_e, $len);
break;
}
function info($start, $end, $len) {
$combos = pow($end - $start, $len);
echo "\n$combos possible combinations\n";
}
?>
|
Usage Example :
| PHP Example : | | <?
0lil-z:/home/zapotek/workspace # ./pwdgen.php 14 -e
1$kK3Ip,]_Ge'CH
23.6204393769E+27 possible combinations
?>
| |
| |

|
 |
| ::: Resources ::: |
|
|
| ::: New Templates ::: |
|
| ::: Other Tutorials ::: |
|
 |