// JWSmythe Password Generator (passgen.php) // (c) 2014 - JWSmythe - http://jwsmythe.com/password/ // // This is publically licensed under the // Creative Commons Attribution 3.0 United States (CC BY 3.0 US) // // This code can be used by anyone. If this code is used, in full // or in part, you must provide a link and the (c) and (cc) notices // above. // // Improvements to this code are welcome. Initiate contact with // us via our contact form on http://jwsmythe.com/ // // We would appreciate, but do not require, that you would notify us // if you choose to use this code in your projects, with your company, // or agency. Such contact will remain confidential. It's nice to // know that someone appreciated it enough to use. // // Projects that people use get more attention and further maintenance. // // http://creativecommons.org/licenses/by/3.0/us/legalcode // // Changes: // // v2.3 14-Feb-2024 // * Added websafe special characters, included by default. // * Trapped request to generate passwords with no character sets selected. // // v2.2 15-Oct-2022 // * Updated Blocks.txt to 15.0.0 // * Added source links and information under Extra Character Sets box. // // v2.1 09-Mar-2021 // * Fixed missing predefs ($debugchecked) // // v2.0 25-Jun-2014 // * Provided space character as checkbox option // * Changed numbers ([2-9]) to be numbers [0-9] and [2-9] separately. // This was previously available by selecting both "numbers" and "ambiguous" // * Added alphahex only, for generating Base16 strings // (like html colors, uuid, MAC address, etc) // * Added custom pool. All characters entered, except ltrim(rtrim()) are used. // Using NUL will probably fail in the browser, but the script will still work. // If you type a NUL, you deserve getting a NUL result. :) // * Cleaned up character pool parsing, to ensure unique characters. // This was only necessary with adding [2-9], [0-9], and custom pool. // * Correct sloppy HTML. Now it validates clean at W3C as HTML5 and CSS3. // Validation buttons and link added to the bottom of the page. // v1.1 (various - unofficial) // * Added alphahex. // * Changed defaults. // v1.0 25-Oct-2012 // // Some source references. // http://web.simmons.edu/~benoit/multilingual.html // http://www.unicode.org/Public/UNIDATA/ // ----------------------------------------------------------------------------- // // This section is for formatting on my site. // If you reuse it, you'll need to remove this. // ----------------------------------------------------------------------------- // $page_name = "JWSmythe Password Generator"; include_once("../../header.php"); // This should be turned on for your site. /* print "
" . print_r($_REQUEST, TRUE) . ""; }; // If this hasn't been used, all checked values will be null. Populate them in a friendly fashion. if ( (empty($_REQUEST['numchar'])) && (empty($_REQUEST['numbers09'])) && (empty($_REQUEST['numbers29'])) && (empty($_REQUEST['upper_letters'])) && (empty($_REQUEST['lower_letters'])) && (empty($_REQUEST['special'])) && (empty($_REQUEST['special_websafe'])) && (empty($_REQUEST['highascii'])) && (empty($_REQUEST['ambiguous'])) && (empty($_REQUEST['format'])) && (empty($_REQUEST['space'])) && (empty($_REQUEST['alphahexonly'])) && (empty($_REQUEST['customchars'])) ){ $numchar = "24"; $numpass = "20"; $numbers29 = "checked"; $numbers09 = ""; $upper_letters = "checked"; $lower_letters = "checked"; $special = ""; $special_websafe = "checked"; $ambiguous = ""; $highascii = ""; $format_form = "checked"; $debug = ""; }else{ // reinforce limits. if (intval($_REQUEST['numpass']) >= 50){ $numpass = 50; }; // more may slow the page render down on mobile devices. if (intval($_REQUEST['numchar']) >= 1 ){ $numchar = $_REQUEST['numchar']; }else{ $numchar = 8; }; if (intval($_REQUEST['numpass']) >= 1 ){ $numpass = $_REQUEST['numpass']; }else{ $numpass = 8; }; // checkboxes if ($_REQUEST['numbers29'] == "on"){ $numbers29 = "checked"; }else{ $numbers29 = ''; }; if ($_REQUEST['numbers09'] == "on"){ $numbers09 = "checked"; }else{ $numbers09 = ''; }; if ($_REQUEST['upper_letters'] == "on"){ $upper_letters = "checked"; }else{ $upper_letters = ''; }; if ($_REQUEST['lower_letters'] == "on"){ $lower_letters = "checked"; }else{ $lower_letters = ''; }; if ($_REQUEST['special'] == "on"){ $special = "checked"; }else{ $special = ''; }; if ($_REQUEST['special_websafe'] == "on"){$special_websafe = "checked"; }else{ $special_websafe = ''; }; if ($_REQUEST['highascii'] == "on"){ $highascii = "checked"; }else{ $highascii = ''; }; if ($_REQUEST['ambiguous'] == "on"){ $ambiguous = "checked"; }else{ $ambiguous = ''; }; if ($_REQUEST['space'] == "on"){ $space = "checked"; }else{ $space = ''; }; if ($_REQUEST['alphahexonly'] == "on"){ $alphahexonly = "checked"; }else{ $alphahexonly = ''; }; if ($_REQUEST['debug'] == "on"){ $debugchecked = "checked"; }else{ $debugchecked = ''; }; if ($_REQUEST['format'] == "form"){ $format_form = "checked"; $format_text = ""; }elseif($_REQUEST['format'] == "text"){ $format_form = ""; $format_text = "checked"; }else{ $format_form = "checked"; $format_text = ""; }; }; if (isset($_REQUEST['customchars'])){ $customchars = $_REQUEST['customchars']; }; if ($numbers09 == "checked"){ $chars .= "0123456789"; }; if ($numbers29 == "checked"){ if ($ambiguous == "checked"){ $chars .= "01"; }; $chars .= "23456789"; }; if ($upper_letters == "checked"){ $chars .= "ABCDEFGHJKMNPQRSTUVWXYZ"; if ($ambiguous == "checked"){ $chars .= "ILO"; }; }; if ($lower_letters == "checked"){ $chars .= "abcdefghjkmnpqrstuvwxyz"; if ($ambiguous == "checked"){ $chars .= "ilo"; }; }; if ($special == "checked"){ $chars .= "!@#%^&*()_+-=[]{}|;:<>?/.,~`\'\"\$"; if ($ambiguous == "checked"){ # Unused in this context. }; }; if ($special_websafe == "checked"){ $chars .= "!@^*()_+-=[]{}|;:.,~"; if ($ambiguous == "checked"){ # Unused in this context. }; }; if (isset($customchars)){ $chars .= $customchars; }; if ($highascii == "checked"){ for ($i=161; $i<=255; $i++){ // $showcurchar = urlencode(chr($i)); // $showcurchar = mb_convert_encoding(chr($i), 'HTML-ENTITIES', "UTF-8"); // $showcurchar = htmlentities(chr($i), ENT_QUOTES, 'cp1252'); // $showcurchar = htmlentities(chr($i), ENT_QUOTES, 'UTF-8'); // $showcurchar = htmlentities(html_entity_decode(chr($i), ENT_COMPAT,'ISO-8859-1')); $html_char = "$i;"; $char = mb_convert_encoding("$html_char", 'UTF-8', 'HTML-ENTITIES' ); if ($debug == 'on'){ print "High Ascii Adding $i - " . $char . "
" . print_r($disp_charset, TRUE) . ""; // // $disp_charset = htmlentities($disp_charset, ENT_HTML5, "UTF-8"); if ($debug == 'on'){ print "
" . print_r($chars, TRUE) . ""; }; $chararray = preg_split('/(?\$chararray
" . print_r($chararray, TRUE) . ""; }; $chararray = array_unique($chararray, SORT_REGULAR); if ($debug == 'on'){ print "
" . print_r($chararray, TRUE) . ""; }; $chars = join("", $chararray); if ($debug == 'on'){ print "
" . print_r($chars, TRUE) . ""; }; $disp_charset = join(" ", $chararray); if ($debug == 'on'){ print "
" . print_r($chars, TRUE) . ""; }; if (!isset($format_text)){ $format_text = ''; }; if (!isset($format_form)){ $format_form = ''; }; print "
Password | |
"; }; // Scale the result box by the number of characters plus a little. // The font is 12px, so we're rescaling it by 14px. $resultboxsize = ($numchar * 9) + 12; $pcount = 0; while ($pcount < $numpass){ $pcount++; $thispass = generate_password($numchar, $chars); // $fieldsize = $numchar+2; // This is our old box scaling. if ($format_form){ // class='results' // Our old input result box. // print " | |
$pcount of $numpass | |
"; }; print " |
(\"All\" is disabled. There are too many characters. Your browser would crash.)