Revision: 52611
Updated Code
at November 18, 2011 02:38 by zogmund
Updated Code
function generatePasswords( $howMany = 10, $length = 6, $allowedChars = NULL ) { if (NULL == $allowedChars) { $allowedChars = 'abcdefghijklmnopqrstuvwxyz0123456789'; } $allowedChars = (string)$allowedChars; $allowedCharsLength = strlen( $allowedChars ); $allowedCharsUpper = strtoupper( $allowedChars ); $pwds = array(); $count = 0; while ($count < $howMany) { for ($j = $howMany - $count; $j--;) { $code = ''; for ($i = $length; $i--;) { $rand = mt_rand(0, $allowedCharsLength - 1); if ($rand % 2) { $code .= $allowedChars{$rand}; } else { $code .= $allowedCharsUpper{$rand}; } } $pwds[$code] = ''; } $count = count( $pwds ); } return array_keys( $pwds ); }
Revision: 52610
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 27, 2011 19:50 by zogmund
Initial Code
function generatePasswords( $howMany = 10, $length = 6, $allowedChars = NULL ) { if (NULL == $allowedChars) { $allowedChars = 'abcdefghijklmnopqrstuvwxyz0123456789'; } $allowedChars = (string)$allowedChars; $allowedCharsLength = strlen( $allowedChars ); $allowedCharsUpper = strtoupper( $allowedChars ); $pwds = array(); $count = 0; while ($count < $howMany) { for ($j = $howMany - $count; $j--;) { $code = ''; for ($i = $length; $i--;) { $rand = mt_rand(0, $allowedCharsLength - 1); if ($rand % 2) { $code .= $allowedChars{$rand}; } else { $code .= $allowedCharsUpper{$rand}; } } $pwds[$code] = ''; } $count = count( $pwds ); } return $pwds; }
Initial URL
Initial Description
Initial Title
unique password|code generator
Initial Tags
php
Initial Language
PHP