Files

205 lines
6.9 KiB
HTML

<html>
<head>
<title>Passgen 0.2.9</title>
<script>
var alphau = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var alphal = "abcdefghijklmnopqrstuvwxyz";
var numbers = "0123456789";
var symbols = "`~!@#$%^&*()-=_+[]\{}|;':\",./<>?\\";
var space = " ";
var baseYear = 120000000000000000000000;
function $id(id) {
return document.getElementById(id);
}
async function copyInputToClipboard(inputId, buttonElement) {
const inputElement = document.getElementById(inputId);
if (!inputElement) return;
try {
await navigator.clipboard.writeText(inputElement.value);
} catch (err) {
inputElement.select();
document.execCommand('copy');
}
// Temporary button label change
if (buttonElement) {
const originalText = buttonElement.innerText;
buttonElement.innerText = 'Copied!';
setTimeout(() => {
buttonElement.innerText = originalText;
}, 2000);
}
}
function secureRand(min,max,len) {
var str = "";
var rand = [];
var pos = 0;
while(rand.length<len) {
var buf = new Uint8Array(512);
window.crypto.getRandomValues(buf);
for(i=0;i<buf.length;i++) {
if(buf[i] >= min && buf[i] <= max) {
rand[pos] = buf[i];
pos++;
}
}
}
return rand.slice(0,len);
}
function generatepass(len,keys){
rlist='';
var srand = secureRand(0,keys.length,len);
for (i=0;i<len;i++) {
rlist+=keys.charAt(srand[i]);
}
return rlist;
}
function entropy(chars,len) {
return Math.round((Math.log(Math.pow(chars,len))/Math.log(2))*100)/100;
}
// chars = length of charset
// len = length of password
// base = total md5 tries per year
// TODO: Assumes power doubles every 18 months (Moore's law)
function yearsToCrack(chars,len,base) {
possible = Math.pow(chars,len);
return Math.round(possible/baseYear);
}
function generate() {
var len = $id('length').value;
var keylist = "";
if($id('alphal').checked) { keylist += alphal; }
if($id('alphau').checked) { keylist += alphau; }
if($id('symbols').checked) { keylist += symbols; }
if($id('numbers').checked) { keylist += numbers; }
if($id('space').checked) { keylist += space; }
$id('out').value = generatepass(len,keylist);
$id('entropy').innerHTML = entropy(keylist.length,len);
$id('years').innerHTML = yearsToCrack(keylist.length,len,baseYear);
}
window.onload = function(){generate();}
</script>
<style>
* {
font-family: 'Courier New', Courier, monospace;
font-weight: bold;
}
body {
background-color: #FFFFFF;
}
h1 {
margin-bottom: 5px;
}
a:link {
color: #000000;
}
a:hover {
text-decoration:none;
}
/* Base link styling */
.has-tooltip {
position: relative; /* Crucial for positioning the tooltip relative to the link */
text-decoration: underline;
cursor: pointer;
}
/* Tooltip container (text box) */
.has-tooltip::before {
content: attr(data-tooltip); /* Pulls text from the data-tooltip attribute */
position: absolute;
bottom: 100%; /* Positions the box above the top of the link */
left: 50%;
transform: translateX(-50%) translateY(-8px); /* Centers horizontally & lifts up slightly */
/* Visual styling */
background-color: #1e293b;
color: #ffffff;
padding: 6px 12px;
border-radius: 6px;
font-size: 0.85rem;
white-space: nowrap; /* Prevents text from wrapping */
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
/* Hide by default */
opacity: 0;
visibility: hidden;
transition: opacity 0.2s ease, transform 0.2s ease;
pointer-events: none; /* Prevents cursor interference */
z-index: 100;
}
/* Tooltip arrow pointer */
.has-tooltip::after {
content: '';
position: absolute;
bottom: 100%;
left: 50%;
transform: translateX(-50%) translateY(0);
/* Creates a small downward arrow using border tricks */
border-width: 6px 6px 0 6px;
border-style: solid;
border-color: #1e293b transparent transparent transparent;
/* Hide by default */
opacity: 0;
visibility: hidden;
transition: opacity 0.2s ease, transform 0.2s ease;
pointer-events: none;
z-index: 100;
}
/* Hover State - Reveal Tooltip & Arrow */
.has-tooltip:hover::before,
.has-tooltip:hover::after {
opacity: 1;
visibility: visible;
}
/* Subtle upward slide animation on hover */
.has-tooltip:hover::before {
transform: translateX(-20%) translateY(-12px);
}
.has-tooltip:hover::after {
transform: translateX(-20%) translateY(-6px);
}
</style>
</head>
<body>
<h1>Passgen<sup><a href="javascript:alert('Passgen 0.2.9\nCryptographically secure password generator\n\nHere is how passgen protects you:\n* Uses a cryptographically secure random number generator to\ngenerate a properly random secure password\n* Nothing is ever sent to anyone! It all runs through your browser\n* Even visiting a website and loading pages from it is not needed\npassgen can run through a bookmarklet without even being online\n* Nothing is ever, ever stored or logged\n* The web page you got this from keeps no logs including IP logs or even a hit counter\n* The website you got this from is secured with TLS to ensure this bookmarklet was not tampered with in transit\n* This bookmarklet code is singed with PGP to guarantee it has not been tampered with by a hacker\n\nPrincess Pi - https://git.thecoven.info/PrincessPi');">?</a></sup></h1>
<input type="checkbox" id="alphal" onchange="generate()" checked> <label for="alphal">Lowercase Letters</label><a href="#" class="has-tooltip" data-tooltip="abcdefghijklmnopqrstuvwxyz">?</a><br>
<input type="checkbox" id="alphau" onchange="generate()" checked> <label for="alphau">Uppercase Letters</label><a href="#" class="has-tooltip" data-tooltip="ABCDEFGHIJKLMNOPQRSTUVWXYZ">?</a><br>
<input type="checkbox" id="numbers" onchange="generate()" checked> <label for="numbers">Numbers</label><a href="#" class="has-tooltip" data-tooltip="0123456789">?</a><br>
<input type="checkbox" id="symbols" onchange="generate()" checked> <label for="symbols">Symbols</label><a href="#" class="has-tooltip" data-tooltip="`~!@#$%^&*()-=_+[]\{}|;':&quot;,.&lt;>?\">?</a><br>
<input type="checkbox" id="space" onchange="generate()" checked> <label for="space">Space</label><a href="#" class="has-tooltip" data-tooltip="Space AKA 0x20, \\s, %20, and &amp;nbsp;">?</a><br>
<label for="length">Length</label> <input type="text" id="length" size="4" value="23" onchange="generate()"><br><br>
<button value="Generate" onclick="generate()">Generate New</button> <!--<input type="button" value="Close" onclick="window.close()">-->
<p><b>Password</b> <input type="text" id="out" size="40" readonly> <button onclick="copyInputToClipboard('out', this)">Copy</button></p>
<p><b>Strength<sup><a href="#" class="has-tooltip" data-tooltip="Bits of entropy. log2(characters^length)">?</a></sup></b> <span id="entropy"></span> bits</p>
<p><b>Years to Crack<sup><a href="#" class="has-tooltip" data-tooltip="WORK IN PROGRESS&#x0A;&#x0D;Assumes all computing power on Earth being used collaboratively, doubling in power every 18 months.&#x0A;&#x0D;Also assumes a weak hash, MD5. (EXCLUDES collisions in MD5)">?</a></sup></b> <span id="years"></span></p>
</body>
</html>