Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Friday, October 16, 2026

Diff for phpPlatonLib/common/rand/Attic/fnc.rand_pass.php between version 1.1 and 1.2

version 1.1, 2002/04/20 10:00:43 version 1.2, 2002/04/21 23:21:20
Line 1 
Line 1 
 <?php  <?php
   
 /**  /*
  * rand_pass()   * phpPlatonLib - Platon software development group PHP library
  *   *
  * Purpose: Returns a random but pronounceable password.   * common/rand/fnc.rand_pass.php - return pronounceable random key
  * Note: You may edit the $num_letters and $array variables   * Note:    You may edit the $num_letters and $array variables
  *   * Author:  Sebastien Cevey <seb@cine7.net>
  * Author: Sebastien Cevey <seb@cine7.net>  
  * Project: Web OpenScripts <http://wos.sourceforge.net>   * Project: Web OpenScripts <http://wos.sourceforge.net>
    * ____________________________________________________________
    *
    * Developed by Ondrej Jombik <nepto@pobox.sk>
    * Copyright (c) 2001-2002 Platon SDG, http://www.platon.sk/
    * All rights reserved.
    *
    * See README file for more information about this software.
    * See COPYING file for license information.
    *
    * Download the latest version from
    * http://www.platon.sk/projects/phpPlatonLib/
  */   */
   
 function rand_pass()  /* $Id$ */
 {  
         // Pronounceable pieces of words  if (! defined('phpPlatonLib_fnc_rand_pass')) {
         $array = array(          define('phpPlatonLib_fnc_rand_pass', 1);
                         "ap","baz","car","dus","tin","rog","sti","rev","pik","sty","lev","qot","rel","vid",  
                         "kro","xo","pro","wia","axi","jer","foh","mu","ya","zol","gu","pli","cra",  
                         "den","bi","sat","ry","qui","wip","fla","gro","tav","peh","gil","lot",  
                         "kal","zan","noc","bat","tev","lun","pal","hom","cun","wos","vox"  
                         );  
   
   
         // Minimum number of letters  
         $num_letters = 6;  
   
         // Maximum number of letters  
         $max_letters = 10;  
   
         // Fraction of uppercased letters (randomized too...)  
         $uppercased = 0;  
   
         // Randomize on microseconds  
         mt_srand ((double)microtime() * 1000000);  
   
         // Create random pass (too long for the moment)  
         for($i = 0; $i < $num_letters; $i++)  
                 $pass .= $array[mt_rand(0, (count($array) - 1))];  
   
         //print "$pass ";  
   
         // Make sure there is not twice the same letter one after the other  
         for($i = 1; $i < strlen($pass); $i++) {  
                 if(substr($pass, $i, 1) == substr($pass, $i - 1, 1))  
                         $pass = substr($pass, 0, $i) . substr($pass, $i + 1);  
         }  
   
         // Randomize the pass case [for each letter]          function rand_pass()
         if ($uppercased)          {
                 for($i = 0; $i < strlen($pass); $i++) {                  // Pronounceable pieces of words
                         if(mt_rand(0, $uppercased) == 0)                  $array = array(
                                 $pass = substr($pass,0,$i)                                  'ap', 'baz', 'car', 'dus', 'tin', 'rog', 'sti',
                                         . strtoupper(substr($pass, $i,1))                                  'rev', 'pik', 'sty', 'lev', 'qot', 'rel', 'vid',
                                         . substr($pass, $i + 1);                                  'kro', 'xo', 'pro', 'wia', 'axi', 'jer', 'foh',
                                   'mu', 'ya', 'zol', 'gu', 'pli', 'cra', 'den',
                                   'bi', 'sat', 'ry', 'qui', 'wip', 'fla', 'gro',
                                   'tav', 'peh', 'gil', 'lot', 'kal', 'zan', 'noc',
                                   'bat', 'tev', 'lun', 'pal', 'hom', 'cun', 'wos', 'vox'
                                   );
   
                   // Minimum number of letters
                   $num_letters = 6;
   
                   // Maximum number of letters
                   $max_letters = 10;
   
                   // Fraction of uppercased letters (randomized too...)
                   $uppercased = 0;
   
                   // Randomize on microseconds
                   mt_srand ((double)microtime() * 1000000);
   
                   // Create random pass (too long for the moment)
                   for($i = 0; $i < $num_letters; $i++)
                           $pass .= $array[mt_rand(0, (count($array) - 1))];
   
                   //print "$pass ";
   
                   // Make sure there is not twice the same letter one after the other
                   for($i = 1; $i < strlen($pass); $i++) {
                           if(substr($pass, $i, 1) == substr($pass, $i - 1, 1))
                                   $pass = substr($pass, 0, $i) . substr($pass, $i + 1);
                 }                  }
   
                   // Randomize the pass case [for each letter]
                   if ($uppercased)
                           for($i = 0; $i < strlen($pass); $i++) {
                                   if(mt_rand(0, $uppercased) == 0)
                                           $pass = substr($pass,0,$i)
                                                   . strtoupper(substr($pass, $i,1))
                                                   . substr($pass, $i + 1);
                           }
   
                   // Shorten it now
                   $pass = substr($pass, 0, $num_letters
                                   + mt_rand(0,$max_letters - $num_letters));
   
         // Shorten it now                  // Return the password
         $pass = substr($pass, 0, $num_letters + mt_rand(0,$max_letters - $num_letters));                  return $pass;
           }
   
         // Return the password  
         return $pass;  
 }  }
   
 ?>  ?>

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top