ASPN ActiveState Programmer Network  
ActiveState, a division of Sophos
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups
Submit Recipe
My Recipes

All Recipes
All Cookbooks


View by Category

Title:  Random Password Generator By Rohit D'souza
Submitter: rohit d'souza (other recipes)
Last Updated: 2006/06/23
Version no: 1.1
Category: Numbers

 

Not Rated yet


Description:

Its help to generate Unique 10 character password on every reload of the page

Usage: Text Source

#!/usr/bin/perl

    @myarray=(A,B,C,1,2,3,4,5,6,7);
    for($i=0;$i<$#myarray;$i++)
    {
    $j=rand(10);
    $randomnum.=$myarray[$j];
    }
    print $randomnum;

The license for this recipe is available here.

Discussion:



Add comment

Number of comments: 4

Minor correction, Satyam Sinha, 2006/05/30
Hi,
The array should be defined with an @myarray instead of $myarray. $# will not really work as expected.
Seems like a typo.


Add comment

Minor correction, Satyam Sinha, 2006/05/30
Hi,
The array should be defined with an @myarray instead of $myarray. $# will not really work as expected.
Seems like a typo.


Add comment

Minor correction, Satyam Sinha, 2006/05/30
Hi,
The array should be defined with an @myarray instead of $myarray. $# will not really work as expected.
Seems like a typo.


Add comment

Works but ..., ebo cmoa, 2008/04/17

i think it's better to use this kind of code :

sub generate_password {
    my $password;
    my @chr_chars = (
        33..47, 58..64, 91..96, 123..126,   # Punctuation
        48..57,                             # Numbers
        65..90,                             # Capital letters
        97..122                             # Small letters
    );
    $password .= chr($chr_chars[int(rand(scalar @chr_chars))]) for (0..10);
    return $password;
}

Add comment



Highest rated recipes:

1. Breaking down a URI into ...

2. Extracting HTML URL Links

3. Removing dangerous ...

4. Matching Royal Mail ...

5. Finding Palindromes

6. Finding URLs in text -- ...

7. Extract the Korean ...

8. Validate Domain Names

9. Validating email ...

10. Remove any HTML




Privacy Policy | Email Opt-out | Feedback | Syndication
© 2006 ActiveState Software Inc. All rights reserved.