Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Random password generator
07-28-2010, 06:03 PM
Post: #1
Random password generator
If any1 in here needs some password (or random string) generator in php, here is the way you can get it! Smile

PHP Code:
<?php
$duzina 
rand(10,16); // we are generating string of longitude 10-16 char
$niz_slova 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890()!@#$%^&*';
    
$chars_duzina = (strlen($niz_slova) - 1);
    
$string $niz_slova{rand(0$chars_duzina)};
    for (
$i 1$i $duzina$i++) 
    {
  
$slovo $niz_slova{rand(0$chars_duzina)};
  if (
$slovo != $string{$i 1}) $string .=  $slovo;
    }
    echo 
$string;
?>

If there is any questions, feel free to post! Smile

Read rules Smile
[Image: legislator.png]
Find all posts by this user
Quote this message in a reply
07-28-2010, 08:20 PM
Post: #2
RE: Random password generator
Very good script, interesting algorithm.
I just changed some variables and translated that into English :
PHP Code:
<?php
$length 
rand(10,16); // we are generating string of longitude 10-16 char
$letters 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890()!@#$%^&*';
    
$chars_length = (strlen($letters) - 1);
    
$string $letters{rand(0$chars_length)};
    for (
$i 1$i $length$i++) 
    {
  
$letter $letters{rand(0$chars_length)};
  if (
$letter != $string{$i 1}) $string .=  $letter;
    }
    echo 
$string;
?>
Great job !!!

There's a fine line between genius and insanity. I have erased this line.
Oscar Levant
There's a fine line between an administrator and black hat hacker. I have erased this line.
Dr DEBCOL
Visit this user's website Find all posts by this user
Quote this message in a reply
07-29-2010, 06:09 AM
Post: #3
RE: Random password generator
Very interesting script Big Grin but in php ..what exactly does '.=' do. Is it appending characters onto the string?

"Character is determined more by the lack of certain experiences than by those one has had."
Friedrich Nietzsche
Visit this user's website Find all posts by this user
Quote this message in a reply
07-29-2010, 07:25 AM (This post was last modified: 07-29-2010 07:28 AM by l3g1sl4tor.)
Post: #4
RE: Random password generator
adding a letter to a string, yea Smile just paste it on alredy existing string Smile

Read rules Smile
[Image: legislator.png]
Find all posts by this user
Quote this message in a reply
07-29-2010, 02:27 PM
Post: #5
RE: Random password generator
nice source code
Visit this user's website Find all posts by this user
Quote this message in a reply
08-02-2010, 01:08 AM
Post: #6
RE: Random password generator
(07-29-2010 06:09 AM)Back_track Wrote:  Very interesting script Big Grin but in php ..what exactly does '.=' do. Is it appending characters onto the string?
It's used to concat a string to an existing string.

Free image hosting at http://myph.us.
Find all posts by this user
Quote this message in a reply
08-02-2010, 06:41 AM
Post: #7
RE: Random password generator
Yeah concatenation is one of operations on strings.
There is a problem with concatenation that i posted here :
http://www.pro9ramming.com/concatenated-...t-829.html
Maybe this example can clear some things . . .

There's a fine line between genius and insanity. I have erased this line.
Oscar Levant
There's a fine line between an administrator and black hat hacker. I have erased this line.
Dr DEBCOL
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


 Quick Theme: