< >

passwort_generator.html


Quell Code


    
    
 
<!DOCTYPE HTML>
<html lang="de">
<head>
 
<title>Auswertung Seitenclicks</title>
<meta charset="utf-8">
<meta name=viewport content="width=device-width, initial-scale=1">
<style>


    
    
</style>
</head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

    			<div class='primary random_password'>
					
					<section>
						<h2>Quick Password Generator</h2>
						<p>Creates a quick password of numbers &amp; lowercase letters<br>
						Lowercase 'L's, letter 'O's and number '0's are omitted						
						<p><input type="submit" value="Create (8)" data-len="8" class="pwgen button_class">
							<input type="submit" value="Create (12)" data-len="12" class="pwgen button_class">
							<input type="submit" value="Create (16)" data-len="16" class="pwgen button_class">
							<input type="text" size="16" maxlength="16" class="input_class password" readonly>
					</section>
					
					<section>
						<h2>Comprehensive Password Generator</h2>
						<form id='big_passwords'>
							<ul>
								<li><label><input type="checkbox" class="input_class" id="pwlowercase" checked>Use Lowercase Letters <span>abcdefghijklmnopqrstuvwxyz</span></label>
								<li><label><input type="checkbox" class="input_class" id="pwdigits" checked>Use Digits <span>0123456789</span></label>
								<li><label><input type="checkbox" class="input_class" id="pwuppercase">Use Uppercase Letters <span>ABCDEFGHIJKLMNOPQRSTUVWXYZ</span></label>
								<li><label><input type="checkbox" class="input_class" id="pwbasicsymbol">Use Basic Symbols <span>!?#$&amp;*@</span></label>
								<li><label><input type="checkbox" class="input_class" id="pwmoresymbol">Use More Symbols <span>%()+-=[]{}|~.,</span></label>
								<li><label><input type="checkbox" class="input_class" id="pwskipsimilar" checked>Skip Similar Looking Characters <span>0OoIl1</span></label>
								<li><label><input type="checkbox" class="input_class" id="pwunique">All Unique Characters</label>
								<li><label><input type="checkbox" class="input_class" id="pwmethod2">Equal Character Set Probability</label>
								<li><label><input type="text" class="input_class" id="pwlength" value="32" size="3" maxlength="4">Password Length</label>
								<li><label><input type="text" class="input_class" id="pwnum" value="4" size="3" maxlength="3">Number of Passwords to Create</label>
							</ul>
							<div class="error_msg"></div>
							<p><input type="submit" name="pwsubmit" value="Generate Passwords" class="button_class">
						</form>
					
						<textarea readonly class='input_class' id="password_results"></textarea>
					</section>
						
					<section>
						<h2>WPA Password Generator</h2>
						<p>Similar to the quick password generator above,<br>this generator creates passwords with lengths ideal for WPA Wi-Fi networks
						<p><input type="submit" value="Short (12)" data-len="12" class="pwgen button_class">
							<input type="submit" value="Long (32)" data-len="32" class="pwgen button_class">
							<input type="submit" value="Max (63)" data-len="63" class="pwgen button_class">
						<p><input type="text" size="63" maxlength="63" class="input_class password" readonly>
					</section>
					
				</div>
                        								<audio id="snd_done" preload="auto">
							<source src="http://www.whatsmyip.org/sounds/done.ogg" type="audio/ogg">
							<source src="http://www.whatsmyip.org/sounds/done.mp3" type="audio/mp3">
						</audio>
						<audio id="snd_fail" preload="auto">
							<source src="http://www.whatsmyip.org/sounds/error.ogg" type="audio/ogg">
							<source src="http://www.whatsmyip.org/sounds/error.mp3" type="audio/mp3">
						</audio>
<script>
    $(function()
    {
	$("#pwd").addClass("this_page");

	$(".pwgen").click(function()
		{
		var $length = $(this).attr("data-len");
		var $pwd = quick_password($length);
		$(this).closest('section').find('.password').val( $pwd );
		
	//	play_a_sound('snd_done');
		});
	
	$("#big_passwords").submit(function($e)
		{
		$(".error_msg").slideUp('fast');
		$("#password_results").slideUp("fast",function()
			{
			var $pool = new Array();
			if ( $("#pwmethod2").is(":checked") )
				{ var $weighted = true; }
			else
				{ var $weighted = false; }

			if ( $("#pwlowercase").is(":checked") )
				{ $pool.push(new Array(97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122)); }

			if ( $("#pwuppercase").is(":checked") )
				{ $pool.push(new Array(65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90)); }

			if ( $("#pwdigits").is(":checked") )
				{ $pool.push(new Array(48,49,50,51,52,53,54,55,56,57)); }

			if ( $("#pwbasicsymbol").is(":checked") && $("#pwmoresymbol").is(":checked") )
				{ $pool.push(new Array(33,63,35,36,38,42,64,37,40,41,43,45,61,91,93,123,125,124,126,46,44)); }
			else
				{				
				if ( $("#pwbasicsymbol").is(":checked") )
					{ $pool.push(new Array(33,63,35,36,38,42,64)); }

				if ( $("#pwmoresymbol").is(":checked") )
					{ $pool.push(new Array(37,40,41,43,45,61,91,93,123,125,124,126,46,44)); }
				}

			if ( $("#pwskipsimilar").is(":checked") )
				{
				var $newpool = [];
				var $newpoollevel2 = [];
				
				$pool.forEach(function($poollevel2)
					{
					$poollevel2.forEach(function($value)
						{
						if ( $value !== 48 && $value !== 49 && $value !== 73 && $value !== 79 && $value !== 108 && $value !== 111 )
							{ $newpoollevel2.push($value); }
						});
					$newpool.push($newpoollevel2);
					$newpoollevel2 = [];
					});

				$pool = $newpool;
				}
			
			var $pool_length = 0;
			$pool.forEach(function($poollevel2)
				{ $pool_length += $poollevel2.length; });
			
			if (!$weighted)
				{
				var $merged_pool = [];
				$pool.forEach(function($poollevel2)
					{
					$merged_pool = $merged_pool.concat($poollevel2);
					});
				$pool = $merged_pool;
				}

			var $filter = /^[1-9][0-9]*$/;
		
			if ( !$filter.test( $("#pwlength").val() ) )
				{ $("#pwlength").val("16"); }
			var $length = $("#pwlength").val();
		
			if ( !$filter.test( $("#pwnum").val() ) )
				{ $("#pwnum").val("4"); }
			var $pwnum = $("#pwnum").val();
		
			if ( $("#pwunique").is(":checked") && ($length > $pool_length) )
				{
	 	//	play_a_sound("snd_fail");
				$(".error_msg").html("<p>Error: Can't make passwords "+$length+" characters long<br>using only "+$pool_length+" unique characters.").slideDown("fast");
				}
			else if ( $pool_length === 0 )
				{
	 	//	play_a_sound("snd_fail");
				$(".error_msg").html("<p>Error: You must select some characters.").slideDown("fast");
				}
			else
				{
				var $i = 1;
				var $password_array = new Array();
			
				while ($i <= $pwnum)
					{
					$password_array.push(String("000" + $i).slice(-3)+": "+ make_big_pw($pool, $length, $weighted) );
					$i++;
					}
			
				$("#password_results").val( $password_array.join("\n") );
		 //	play_a_sound("snd_done");
				$("#password_results").attr("rows",$pwnum).slideDown("fast");
				}
			});
		
		$e.preventDefault();
		});
		
	});


function make_big_pw($pool,$length,$weighted)
	{
	var $c = 0;
	var $password = new Array();
							
	while ($c < $length )
		{
		if ($weighted)
			{
			var $charclass = Math.floor(Math.random() * $pool.length);
			var $newchar = String.fromCharCode( $pool[$charclass][Math.floor(Math.random()*$pool[$charclass].length)] );
			}
		else
			{
			var $newchar = String.fromCharCode( $pool[Math.floor(Math.random()*$pool.length)] );
			}

		if ( $("#pwunique").is(":checked") )
			{
			if ( $.inArray($newchar,$password) === -1)
				{
				$password.push($newchar);
				$c++;
				}
			}
		else
			{
			$password.push($newchar);
			$c++;
			}
				
		}									
	return $password.join("");
	}


function quick_password($len)
	{
	var $password = "";
	var $i = 0;
	while ($i < $len)
		{
		var $rand = (Math.floor(Math.random()*35) + 97);
		if ($rand > 122)
			{ $rand -= 75; }
		if ($rand !== 111 && $rand !== 108 && $rand !== 48)
			{
			$password += String.fromCharCode($rand);
			$i++;
			}
		}
	return $password;
	}
	
 
</script>

</body>
</html>