SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    Wibblesticks Gryff's Avatar
    Join Date
    Oct 2001
    Location
    Asgard
    Posts
    442
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Random Password Generator

    $colours = array('blue', 'red', 'green', 'orange',
    'yellow', 'purple', 'pink', 'black');
    $select = rand(0, 7);
    $colour = $colours[$select];
    $second = rand(100,9999);
    $pw = "$colour" . "$second";

    thats my random pw generator atm
    I'm trying to improve its range by upping the number of colours

    blue
    red
    green
    orange
    yellow
    purple
    pink
    black
    Crimson
    Magenta
    Indigo
    Violet
    Navy
    Maroon
    Vermillion
    Azure
    Teal
    Turquoise
    Amber
    Beige
    Olive
    Tan


    Anyone got A) any improvements to my code
    or B) more colours

  2. #2
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you're using colors for random passwords? i don't care how many colors you have, there aren't going to be enough, which means it would be very easy to guess the "random" password. i could try all of those you have there in like 2 minutes. (oh, oops, i see you're putting a random number on the end; much better. )

    but anyway, i would make an array of letters (upper and lowercase) and numbers. pull 6-8 random characters out of it, and you'd have a good random password.
    - Matt ** Ignore old signature for now... **
    Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
    "Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR

  3. #3
    Wibblesticks Gryff's Avatar
    Join Date
    Oct 2001
    Location
    Asgard
    Posts
    442
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Its not for me though.
    I picked colours because they are memorable to the user, rather than some mixture of letters/numbers that is completely random.
    My current script gives me about 80k passwords.
    I was also thinking of assigning a random letter to the end of the string
    so you could have green6369a
    the simple addition increases the number of passwords by 26.
    The whole point is I want something fairly easy to code, memorable for the individual users, and hard to crack.
    To this end my ambition is > 1 million options, which I get right now if I put another letter on the end.
    8x9899x26=2058992.
    So if I double or triple the number of colours I can probably hit about 5 million combinations that is still fairly ok to remember.

  4. #4
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oh, so the users can't change their password? i thought this was just a temporary thing. in that case, it sounds like you'll be doing all right with some numbers/letters on the end. good luck coming up with more colors. "white" is one that you don't have.

  5. #5
    Wibblesticks Gryff's Avatar
    Join Date
    Oct 2001
    Location
    Asgard
    Posts
    442
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    they can change their password. This is the default random password they get issued when they sign up.
    PS: with the current state of the code I have > 8 million possibilities, so come on give me more colours :P

  6. #6
    Wibblesticks Gryff's Avatar
    Join Date
    Oct 2001
    Location
    Asgard
    Posts
    442
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I had another idea to double the number of colours, so effectively taking me to 16.5 million possibilities
    have an alternate colour so both Purple and purple are options, you could also capitalize other letters, but it wouldnt be as memorable, which is still one of the main aims.

  7. #7
    Wibblesticks Gryff's Avatar
    Join Date
    Oct 2001
    Location
    Asgard
    Posts
    442
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    doh

    anyway I knew someone had posted a better version at somepoint from an old thread, but I couldnt find it
    I managed to find it so here it is ( thanks freddy )

    srand((double)microtime() * 10000);
    $colours = array('blue', 'red', 'green', 'orange',
    'yellow', 'purple', 'pink', 'black');
    $colour = $colours[array_rand($colours)];


    It saves you adding the whole numbers thing if you add more colours/letters, which would have saved me some time when adding 30+ new colours

  8. #8
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    bergandy (sp?)

    That browish redish colour...


    How about...

    I dunno...

  9. #9
    Wibblesticks Gryff's Avatar
    Join Date
    Oct 2001
    Location
    Asgard
    Posts
    442
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I found a big list of colours @
    http://www.dtp-aus.com/colrname.htm

  10. #10
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    wow...


Bookmarks

Posting Permissions

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