CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Password Generator

 



zylon
New User

Aug 16, 2007, 6:02 PM

Post #1 of 7 (2136 views)
Password Generator Can't Post

Well I'm trying to make a PassGen with perl. Here is my source so far. I want Perl to do random pairing of my word combinations. But I dont know how. Can someone please help me? much will be appreciated.




Code
   

#!/usr/local/bin/perl
#Froweey Owns


print "Please press a key to continue nab.";
$d = <STDIN>;
chop $d;
while ($d ne "start")
{
print " Password Generator Created by Froweey //// Type 'start' to begin my program:";
$d = <STDIN>;
chop $d;
}



if ($d)
{
print "Starting....\n";
}
elsif (length($a) == 1)
{
print "FAILED!\n";
}


print "Username: ";
$a = <STDIN>;
chop $a;
while ($a ne "froweey")
{
print "Invalid Username! Username: ";
$a = <STDIN>;
chop $a;
}


print "Password: ";
$b = <STDIN>;
chop $b;
while ($b ne "test")
{
print "Invalid Password! Password:";
$b = <STDIN>;
chop $b;
}

print "\n";
print "Type 'make' to create a Safe password";
print "\n";
print "Create Password: ";
$c = <STDIN>;
chop $c;
while ($c ne "make")
{
print "Invalid Command!";
$c = <STDIN>;
chop $c;
}


$a = 'nablar';
$b = 'headz';

$c = 'fhgfhfg';
$d = 'ggf556hgfhf';

$e = 'dfghfd456gdffgh';
$f = 'hbgfh45645fghfdgvfd';

$g = 'fhgfdfgfdg';
$h = 'dff654dg';

$i = 'dfbtrgd';
$j = 'ewr6yh6';

$k = 'fds5454';
$l = 'sadascg';

$m = '768hhty';
$n = 'rw4r4eg';

$o = 'fgfdjfg';
$p = 'gmukuyj';

$q = 'fdsvbnh';
$r = '5778igf';

$s = 'sdfcxcz';
$t = '8779jyh';

$u = '453gtyt';
$v = 'lolujhh';

$w = 'hfgbcvs';
$x = 'zzzzzza';

$y = '999ghgd';
$Z = '1111dvg';

print "\n";

if ($a)
{
print "The passwords created are safe!\n";
}
else
{
print "The passwords can be guessed!\n";
}

print "\n";
print $a.''.$b;
print "\n";
print $c.''.$d;
print "\n";
print $e.''.$f;
print "\n";
print $g.''.$h;
print "\n";
print $i.''.$j;
print "\n";
print $k.''.$l;
print "\n";
print $m.''.$n;
print "\n";
print $o.''.$p;
print "\n";
print $q.''.$r;
print "\n";
print $s.''.$t;
print "\n";
print $u.''.$v;
print "\n";
print $w.''.$x;
print "\n";
print $y.''.$z;

print "\n";
print "\n";

if (!$a)
{
print "The Passwords Creation FAILED!\n";
}
elsif (length($a) == 1)
{
print "ERROR: Passwords must have more than 1 character!\n";
}
elsif (length($a) == 2)
{
print "Passwords have less than 2 characters!! it is so e z to hack it!\n";
}

elsif (length($a) == 6)
{
print "Passwords have more than 6 characters... therefore they are SAFE!\n";
}
elsif (length($a) == 13)
{
print "Password have more than 13 characters... therefore they are REALLY SAFE!!!\n";
}
else
{
print "Passwords are not Safe!\n";
}


select(undef, undef, undef, 1000.25);



KevinR
Veteran


Aug 17, 2007, 8:31 AM

Post #2 of 7 (2131 views)
Re: [zylon] Password Generator [In reply to] Can't Post

Is this school/class/course work of some kind?
-------------------------------------------------


seamanrob2004
Novice


Aug 19, 2007, 3:49 AM

Post #3 of 7 (2118 views)
Re: [zylon] Password Generator [In reply to] Can't Post

zylon,
i dont know if this helps but i found this code a few years ago and use it for most of my password requirements....


Code
srand(); 
$trigger = int(rand(1000)+1);

srand($trigger ^ time);
@c=split(/ */, "bcdfghjklmnprstvwxyz");
@v=split(/ */, "aeiou");
for ($i = 1; $i <=4; $i +=1) {
$nmonic .="$c[int(rand(20))]$v[int(rand(5))]";
}


where $nmonic is a randomly generated meaningless phrase...

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
veritas vos liberabit ~ The truth shall set you free


KevinR
Veteran


Aug 19, 2007, 4:50 AM

Post #4 of 7 (2117 views)
Re: [seamanrob2004] Password Generator [In reply to] Can't Post

You realize that can potentially gen passwords like "fuck" and "shit"? To avoid awkward passwords like that don't include any vowels. It's also better to add digits into the mix and use a minimum of 6 characters, although 7 is exponentially much better. srand() has also not been necessary for a long time. Here is a random password generator I recently wrote for an article on another forum, you might find it interesting:




Code
# Call the rand_pass() subroutine from 
# anywhere in a perl script to generate
# a random password.

my $password = rand_pass();
# now do something with $password :)

# Place this subroutine anywhere in a perl
# script to pass back a password for use
# as needed.

sub rand_pass {

# An array of characters used to make the passwords.
# Lower-case 'L' and the number one '1' as well a
# lower-case 'O' and the number zero '0' are omitted
# to avoid confusion between them. Upper-case alpha
# characters could be added if mixed-case passwords
# are desired.
my @chars = ('a'..'k','m','n','p'..'z','2'..'9');

# The number of characters to use in passwords
my $length = 12;

# Initialize an empty string.
my $password = '';

# A loop to get random characters from the array
# and concatenate them into a password.
for (1..$length) {
$password .= $chars[int rand @chars];
}

#return the password back.
return $password;
}

-------------------------------------------------


seamanrob2004
Novice


Aug 19, 2007, 5:37 AM

Post #5 of 7 (2115 views)
Re: [KevinR] Password Generator [In reply to] Can't Post

erm.... no it cant.

It takes one consonant, one vowel, one consonant another vowel etc etc....

last time i checked, fuck shit and the rest of usually only have one vowel and multiple consonants, so the worst you could come up with is something like fuca!




- besides which, using vowels helps people remember the password. its easier to remember volosora than vtjfkslr

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
veritas vos liberabit ~ The truth shall set you free


(This post was edited by seamanrob2004 on Aug 19, 2007, 5:40 AM)


KevinR
Veteran


Aug 19, 2007, 5:44 AM

Post #6 of 7 (2111 views)
Re: [seamanrob2004] Password Generator [In reply to] Can't Post


Quote
erm.... no it cant.


I need a cup of coffee, or actually I should just go back to bed. You are of course correct, I misread your code, my apologies.
-------------------------------------------------


seamanrob2004
Novice


Aug 19, 2007, 5:47 AM

Post #7 of 7 (2110 views)
Re: [KevinR] Password Generator [In reply to] Can't Post

but for shock value, i may change the code slightly Smile

More coffee I think... (except over here im more of a tea drinker!)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
veritas vos liberabit ~ The truth shall set you free

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives