Passwort-Generator.php


Quell Code


    <script src="https://basti1012.de/js/index.php?js=jquery.js"></script>
<div id="allpw">

<div class="row info">

<div class="col-md-8">
<p class="pg-label">Generator von sicheren Passwörtern</p>
<p class="pg-text">Verwende diesen kostenlosen Passwortgenerator zur Erstellung extrem sicherer Kennwörter, die schwer zu knacken oder zu erraten sind. Wähle einfach die Kriterien des von Ihnen benötigten Passworts aus und klicken Sie auf „Passwort(e) generieren“. Denke daran: Je mehr Optionen Du aussuchen, umso sicherer das Passwort.</p>
</div>
</div>
<div class="row info">

<div class="col-md-8">
<div class="row">
<div class="text-center col-md-5">
<button type="button" class="pg-btn" id="btndefine">BESTIMME PASSWORT</button>
</div>
<div class="text-center col-md-2">
<span>ODER</span>
</div>
<div class="text-center col-md-5">
<button type="button" class="pg-btn pg-btn-2" id="btnrandom">ZUFALLSPASSWORT ERSTELLEN</button>
</div>
</div>
</div>

</div>
<div class="row info">

<div class="col-md-8">
<div class="row">
<div class="text-left col-md-5 opaczero" id="pwordDefine">
<form class="form-inline" method="get" onsubmit="generate(); return false;">
<div id="charset" class="section">
<div id="charset-checkboxes">
<div class="form-horizontal preset-charset">
  
  
<div class="checkbox">
<label for="charset-0">
<label class="chkcontainer"><span class="chktext">Einschließlich Nummern <small>( eg. 123456 )</small></span>
<input type="checkbox" checked="" id="charset-0">
<span class="checkmark"></span>
</label>
</label>
</div>
  
  
</div>
<div class="form-horizontal preset-charset">
  
  
<div class="checkbox">
<label for="charset-1">
<label class="chkcontainer"><span class="chktext"> Einschließlich Kleinbuchstaben <small>( eg. abcdefgh )</small></span>
<input type="checkbox" checked="" id="charset-1">
<span class="checkmark"></span>
</label>
</label>
</div>
  
  
  
</div>
<div class="form-horizontal preset-charset">
  
  
<div class="checkbox">
<label for="charset-2">
<label class="chkcontainer"><span class="chktext"> Einschließlich Großbuchstaben <small>( eg. ABCDEFGH )</small></span>
<input type="checkbox" checked="" id="charset-2">
<span class="checkmark"></span>
</label>
</label>
</div>
  
  
  
</div>
<div class="form-horizontal preset-charset">
  
  
<div class="checkbox">
<label for="charset-3">
<label class="chkcontainer"><span class="chktext">Einschließlich Symbole <small>( eg. {}[]()/\'"~,;:. )</small></span>
<input type="checkbox" id="charset-3">
<span class="checkmark"></span>
</label>
</label>
</div>
  
  
</div>
<div class="form-horizontal preset-charset">
<div class="checkbox">
<label for="charset-4">
<label class="chkcontainer"><span class="chktext">Leerzeichen <small>( )</small></span>
<input type="checkbox" id="charset-4">
<span class="checkmark"></span>
</label>
</label>
</div>
  
  
</div>
<div class="form-horizontal">
<div class="checkbox">
<label>
<label class="chkcontainer" for="custom" id="customlabel"><span class="chktext">Anpassen: <input type="text" class="chckinnertextbox" id="customchars" value="" size="15" style="width:10em; font-size:80%; line-height:1.5" oninput="document.getElementById('custom').checked=true;"> </span>
<input type="checkbox" id="custom"/>
<span class="checkmark"></span>
</label>
  
  
</label>
</div>
</div>
<div class="form-horizontal">
<div class="checkbox">
<label><input type="radio" name="type" id="by-length" checked="checked"> Länge: </label>
<input type="number" min="0" value="10" step="1" id="length" style="width:4em" class="chckinnertextbox" oninput="document.getElementById('by-length').checked=true;"> Zeichen	</div>
</div>
  
  
<div class="form-horizontal">
<div class="checkbox">
<label><input type="radio" name="type" id="by-entropy"> Entropie: </label>
<input type="number" min="0" value="128" step="any" id="entropy" style="width:4em" class="chckinnertextbox" oninput="document.getElementById('by-entropy').checked=true;"> Bits	</div>
</div>
</div>
</div>
<br><br>
<button type="button" class="pg-sm-btn pg-sm-btn-1">GENERIEREN</button>
<span id="password"> </span>
<button type="button" class="pg-sm-btn pg-sm-btn-1 copytoclipboard">KOPIEREN</button>
</form>
</div>
<div class="text-center col-md-5 opaczero" id="pwordRandom">
<div class="form-horizontal">
<span id="smallpassword"> </span>
<button type="button" class="pg-sm-btn pg-sm-btn-1 copytoclipboard">KOPIEREN</button>
</div>
</div>
<div class="row info">
<p class="opaczero" id="statistics"><p>
</div>
</div>
<script>
    
     $(document).ready(function() {
    $('#btndefine').click(function() {
        $('#pwordRandom').addClass('opaczero');
        $('#statistics, #pwordDefine').removeClass('opaczero');
        $('html,body').animate({
            scrollTop: $("#pwordDefine").offset().top
        });
    });
    $('#btnrandom').click(function() {
        $('#pwordRandom').removeClass('opaczero');
        $('#statistics, #pwordDefine').addClass('opaczero');
        generate();
        $('html,body').animate({
            scrollTop: $("#pwordRandom").offset().top
        });
    });
    $('button.copytoclipboard').click(function() {
        var el = $(this).parent().find('span');
        if (el.html() != '&nbsp;' && el.text() != '' && el.text() != ' ') {
            $(this).text('KOPIERT!').addClass('pg-sm-btn-2').removeClass('pg-sm-btn-1');
            var el = $(this).parent().find('span');
            copyToClipboard(el);
        }
    });
    $('#customchars').keyup(function() {
        var txt = $(this).val();
        if (txt == '') {
            $('div.preset-charset').show();
            $('#charset-0, #charset-1, #charset-2').prop('checked', true);
            $('#custom').prop('checked', false);
        } else {
            $('#custom').prop('checked', true);
            $('div.preset-charset').hide().find('input').prop('checked', false);
        }
    });
    $('#customlabel').click(function() {
        if ($('input#custom').is(':checked')) {
            $('#custom').prop('checked', false);
            $('div.preset-charset').show();
            $('#charset-0, #charset-1, #charset-2').prop('checked', true);
        } else {
            $('#custom').prop('checked', true);
            $('#customchars').focus();
        }
        $('#customchars').val('');
    });


function copyToClipboard(element) {
    var $temp = $("<input>");
    $("body").append($temp);
    $temp.val($(element).text()).select();
    document.execCommand("copy");
    $temp.remove();
} 

//use strict ";
var CHARACTER_SETS=[[true,"Numbers ","0123456789 "],
 [true,"Lowercase ","abcdefghijklmnopqrstuvwxyz "],
[false,"Uppercase ","ABCDEFGHIJKLMNOPQRSTUVWXYZ "],
[false,"ASCII symbols ","!\"#$%" + String.fromCharCode(38) + "'()*+,-./:;" + String.fromCharCode(60) + "=>?@[\\]^_`{|}~"], 
[false, "Space", " "],];
var passwordText = document.createTextNode("");
var smallPasswordText = document.createTextNode("");
var statisticsText = document.createTextNode("\u00A0");
document.getElementById("password").appendChild(passwordText);
document.getElementById("smallpassword").appendChild(smallPasswordText);
document.getElementById("statistics").appendChild(statisticsText);

function generate() {
    jQuery('button.copytoclipboard').text('KOPIEREN').addClass('pg-sm-btn-1').removeClass('pg-sm-btn-2');
    var charsetStr = "";
    CHARACTER_SETS.forEach(function(entry, i) {
        if (document.getElementById("charset-" + i).checked) charsetStr += entry[2];
    });
    if (document.getElementById("custom").checked) {
        charsetStr += document.getElementById("customchars").value;
    }
    charsetStr = charsetStr.replace(/ /, "\u00A0");
    var charset = [];
    for (var i = 0; charsetStr.length > i; i++) {
        var c = charsetStr.charCodeAt(i);
        var s = null;
        if (0xD800 > c || c >= 0xE000) s = charsetStr.charAt(i);
        else if (c >= 0xD800 ? 0xDC00 > c : false) {
            if (charsetStr.length > i + 1) {
                var d = charsetStr.charCodeAt(i + 1);
                if (d >= 0xDC00 ? 0xE000 > d : false) {
                    s = charsetStr.substr(i, 2);
                    i++;
                }
            }
        } else if (d >= 0xDC00 ? 0xE000 > d : false) i++;
        else
            throw "Assertion error"; if (s != null ? charset.indexOf(s) == -1 : false) charset.push(s);
    }
    console.log(charset);
    var password = "";
    var statistics = "";
    if (charset.length == 0) 
      alert("Bitte markieren Sie mindestens ein Kästchen");
    else if (document.getElementById("by-entropy").checked ? charset.length == 1 : false) 
      alert("Error: Need at least 2 distinct characters in set");
    else {
        var length;
        if (document.getElementById("by-length").checked) length = parseInt(document.getElementById("length").value, 10);
        else if (document.getElementById("by-entropy").checked) length = Math.ceil(parseFloat(document.getElementById("entropy").value) * Math.log(2) / Math.log(charset.length));
        else
            throw "Assertion error"; if (0 > length) alert("Negative Passwortlänge");
        else if (length > 10000) alert("Passwort ist zu lang");
        else {
            for (var i = 0; length > i; i++) {
                password += charset[randomInt(charset.length)];
            }
            var entropy = Math.log(charset.length) * length / Math.log(2);
            var entropystr;
            if (70 > entropy) entropystr = entropy.toFixed(2);
            else if (200 > entropy) entropystr = entropy.toFixed(1);
            else
                entropystr = entropy.toFixed(0);
            statistics = "Länge = " + length + " Schriftzeichen, \u00A0\u00A0Charset size = " + charset.length + " Symbole, \u00A0\u00A0Entropie = " + entropystr + " Bits";
        }
    }
    passwordText.data = password;
    smallPasswordText.data = password;
    statisticsText.data = statistics;
}

function randomInt(n) {
    var x = randomIntMathRandom(n);
    x = (x + randomIntBrowserCrypto(n)) % n;
    return x;
}

function randomIntMathRandom(n) {
    var x = Math.floor(Math.random() * n);
    if (0 > x || x >= n) throw "Arithmetic exception";
    return x;
}
var cryptoObject = null;

function randomIntBrowserCrypto(n) {
    if (cryptoObject == null) return 0;
    var x = new Uint32Array(1);
    do cryptoObject.getRandomValues(x); while (x[0] - x[0] % n > 4294967296 - n);
    return x[0] % n;
}

function initCrypto() {
    var textNode = document.createTextNode("\u2717");
    if ("crypto" in window) cryptoObject = crypto;
    else if ("msCrypto" in window) cryptoObject = msCrypto;
    else
        return; if (!("getRandomValues" in cryptoObject) || !("Uint32Array" in window) || typeof Uint32Array != "function") cryptoObject = null;
    else
        textNode.data = "\u2713";
}
initCrypto();
    
    });

    </script>
</script>