unknowncheats uc-forum.com ucdownloads ucdownloads.com

Go Back   UC-Tutorials - Multiplayer Game Hacking and Cheat Tutorials > Web / Scripting > PHP

- Sponsored Advertisement -
http://www.myfpscheats.com/


Reply
 
Thread Tools Display Modes
  #1  
Old 04-13-2010, 03:49 AM
learn_more learn_more is offline
Member
 
Join Date: Feb 2010
Posts: 59
Default Random password generator class

by Crucial:

Another one of my scripts, all it does is generate a random password with the desired length the user enters. And the user can check if they want special characters added in(EX:!#$@%^&*()_-+=).

Hope you enjoy it.

index.html
PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<
title>Random Password Generator</title>

    <
link rel="stylesheet" type="text/css" media="all" href="style.css" />


</
head>
<
body>
<
div id="main">
<
form method="post" action="randomgen.php">
        <
h4>Secure Password Generator</h4>
        <
H5>Length of Password MAX(15)</H5><p><input type="text" name "chars" id="chars" size="25"  maxlength="128" value="Number Between 1-15" /></p>
        <
H5>Use Special Characters?(Default = NO)</H5>
        <
small>Yes</small> <input type="radio" name="special" value="1"><br /> <small>No</small> <input type="radio" name="special" value="0"> <br />
        <
p><input type="submit" value="Submit" /></p>
        </
form>
</
div> <!-- End Main -->
</
body>
</
html
style.css
PHP Code:
body {
font-familyhelveticaarialsans-serif;
}

#main {
text-aligncenter;
border1px solid #CFCFCF;
background:#F2F2F2;
min-height250px;
min-width650px;
positionabsolute;
left50%;
margin-left: -352px;
top50%;
margin-top: -165px;

}



h4 {
color#5F5F5F;
font-size23px;
}


h2 {
color:red;
font-size:20px;
}

input#submit{
width2%;
font-size14px;
}

small{
font-size16px;
positionrelative;



randomgen.php

PHP Code:
<?php

class PasswordGenerator
{
    static 
$password '';
    static 
$characters 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';

    public function 
generatePassword()
    {
        
$num_chars stripslashes($_POST['chars']);
        
$special_chars stripslashes($_POST['special']);
        
        if(
$num_chars 15)
        {
            die(
'ERROR:To Many Characters');
        }
        if(
$num_chars 1)
        {
            die(
'ERROR:You did not enter a length');
        }
        
        if(
$special_chars == 1)
        {
            
self::$characters .= '!#$@%^&*()_-+=';  
        }
    
        
$i=0;
        while (
$i $num_chars) { 
            
$char substr(self::$charactersmt_rand(0strlen(self::$characters)-1), 1);

            if (!
strstr(self::$password$char))
            { 
                
self::$password .= $char;
                
$i++;
            }
        }
    return 
self::$password;
  }
}


?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Random Password Generator</title>

    <link rel="stylesheet" type="text/css" media="all" href="style.css" />


</head>
<body>
<div id="main">

        <h4>Generated password:</h4><h2><?php echo PasswordGenerator::generatePassword(); ?><h2>
        <p><a href="index.html">Return To Generator?</a></p>
        
</div> <!-- End Main -->
</body>
</html>
Reply With Quote
Reply

  • Submit Thread to Digg
  • Submit Thread to del.icio.us
  • Submit Thread to StumbleUpon
  • Submit Thread to Google
  • Submit Thread to Facebook
  • Submit Thread to My Yahoo!
  • Submit Thread to MySpace
  • Submit Thread to Twitter
  • Submit Thread to Reddit

Tags
class, generator, password, random

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



All times are GMT. The time now is 08:51 AM.