Generate Password Snippet by neon

View previous topic View next topic Go down

Generate Password Snippet by neon

Post  ~Fleck on Mon Jun 29, 2009 5:54 am

Code:

<?php

define('CHARS_ALPHA', 'abcdefghijklmnopqrstuvwxyz');
define('CHARS_DIGIT', '0123456789');

function get_random_variable()
{
    $o = substr(str_shuffle(CHARS_ALPHA), 0, 1);

    for($i = 0; $i < 2 + rand() % 9; $i++)
    {
        $c = str_shuffle(strtolower(CHARS_ALPHA) . strtoupper(CHARS_ALPHA) . CHARS_DIGIT);
        $o .= $c[0];
    }

    return $o;
}

echo get_random_variable();

?>

~Fleck
Moderator
Moderator

Posts: 274
Activity: -258
Reputation: 8
Join date: 2009-06-28
Age: 16
Location: 127.0.0.1

Back to top Go down

Re: Generate Password Snippet by neon

Post  misterx on Mon Jun 29, 2009 6:30 am

This code is very easy, but i like to use array_rand() instead of shuffel.

_________________

"You tried, gave your best, and failed. Here's the lesson: "Never try!""
~Homer Simpson

misterx
Admin
Admin

Posts: 59
Activity: -702
Reputation: 1
Join date: 2009-06-27
Age: 14
Location: Estonia

Back to top Go down

View previous topic View next topic Back to top


Permissions of this forum:
You cannot reply to topics in this forum