Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Feb 2008
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    add random number

    Hello,

    This section of my code reads a password list (dictionary.pl) file and randomly selects a word to serve as a password. (i.e violin)

    I would like to modify it so that it adds a random number (or two) to the password. (i.e. violin21)

    Code:
    sub DictionaryPassword
    {
    	my $dict = 'dictionary.pl';
      	open(FILE, "$dict") or Error('File Access Error',"An error occurred when opening the $msg ($file): $!.");
        my @lines = (<FILE>);
        close(FILE)         or Error('File Close Error',"An error occurred when close the $msg ($file): $!.");
    	splice(@lines, 0, 5); #remove top 5 lines
    	foreach $line (@lines) {
    		$line =~ s/(\W)*//ig;
    	}
    
    	return $lines[rand(@lines - 1)];
    }#DictionaryPassword
    Thank you.

  • #2
    New Coder
    Join Date
    Aug 2010
    Location
    India
    Posts
    42
    Thanks
    0
    Thanked 5 Times in 5 Posts
    In place of this,
    return $lines[rand(@lines - 1)];

    put this
    Code:
    return $lines[rand(@lines - 1)].rand(10);


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •