mirror of
https://github.com/Astatin3/StatelessUsb.git
synced 2026-06-08 16:18:01 -06:00
180 lines
4.9 KiB
HTML
180 lines
4.9 KiB
HTML
<!DOCTYPE html>
|
|
<body>
|
|
|
|
<form>
|
|
<input type="file" id="fileInput" accept=".json"><br>
|
|
<select id="dropDown" style="display:none;" onchange="setInput(conf.length-1 - this.selectedIndex)"></select>
|
|
<br>
|
|
<br>
|
|
<input type="input" id="site" placeholder="Site"><br>
|
|
<input type="input" id="username" placeholder="Username / Email">
|
|
<br>
|
|
<br>
|
|
<p>Length: </p><input type="input" id="length" placeholder="Length" value="16"><br>
|
|
<input type="checkbox" id="incLowercase" checked="checked">
|
|
<label for="incLowercase"> Lowercase letters</label>
|
|
<br>
|
|
<input type="checkbox" id="incUppercase" checked="checked">
|
|
<label for="incUppercase"> Uppercase letters</label>
|
|
<br>
|
|
<input type="checkbox" id="incNumber" checked="checked">
|
|
<label for="incNumber"> Numbers</label>
|
|
<br>
|
|
<input type="checkbox" id="incSymbol" checked="checked">
|
|
<label for="incSymbols"> Symbols</label>
|
|
<br>
|
|
<br>
|
|
<input type="password" id="password" placeholder="Master Password">
|
|
<input type="button" id="generate" value="Generate" onclick="genPassword()">
|
|
<input type="button" id="save" value="Save" onclick="saveConf()">
|
|
</form>
|
|
|
|
<style>
|
|
|
|
p {
|
|
display: inline;
|
|
}
|
|
|
|
</style>
|
|
|
|
<script>
|
|
let conf
|
|
|
|
const charLowercase = "qwertyuioppasdfghjklzxcvbnm"
|
|
const charUppercase = "QWERTYUIOPASDFGHJKLZXCVBNM"
|
|
const charNum = "1234567890"
|
|
const charSymbol = "\`~!@#$%^&*()_+[]\\{}|;\':\",./<>?"
|
|
const fullCharset = charLowercase + charUppercase + charNum + charSymbol
|
|
|
|
function getConf(e) {
|
|
var file = e.target.files[0]
|
|
if (!file) {
|
|
return
|
|
}
|
|
let reader = new FileReader();
|
|
reader.onload = function(e) {
|
|
conf = JSON.parse(e.target.result)
|
|
const dropDown = getEl("dropDown")
|
|
dropDown.style.display = ""
|
|
for(let i = 0; i <= conf.length-1; i++){
|
|
let option = document.createElement('option');
|
|
option.text = conf[i].site;
|
|
dropDown.add(option, 0);
|
|
}
|
|
dropDown.selectedIndex = -1
|
|
}
|
|
reader.readAsText(file)
|
|
}
|
|
|
|
document.getElementById('fileInput').addEventListener('change', getConf);
|
|
|
|
function setInput(int){
|
|
getEl("site").value = conf[int].site
|
|
getEl("username").value = conf[int].user
|
|
getEl("length").value = conf[int].length
|
|
getEl("incLowercase").checked = conf[int].lower
|
|
getEl("incUppercase").checked = conf[int].upper
|
|
getEl("incNumber").checked = conf[int].number
|
|
getEl("incSymbol").checked = conf[int].symbol
|
|
}
|
|
|
|
function genPassword(){
|
|
const site = getEl("site").value
|
|
const user = getEl("username").value
|
|
const pass = getEl("password").value
|
|
|
|
const length = getEl("length").value
|
|
|
|
if(!site | !user | !pass | !length){
|
|
alert("Invalid Input")
|
|
return
|
|
}
|
|
|
|
const seed = toInt(site) + toInt(user) + toInt(pass)
|
|
|
|
const isLow = getEl("incLowercase").checked
|
|
const isUp = getEl("incUppercase").checked
|
|
const isNum = getEl("incNumber").checked
|
|
const isSym = getEl("incSymbol").checked
|
|
|
|
result = RandStr(length, seed, isLow, isUp, isNum, isSym)
|
|
copyToClipboard(result)
|
|
alert("Copied to clipboard")
|
|
}
|
|
|
|
function toInt(Str){
|
|
let result = ''
|
|
for(let i = 0; i <= Str.length-1; i++){
|
|
result += fullCharset.indexOf(Str[i]).toString()
|
|
}
|
|
return parseInt(result)
|
|
}
|
|
|
|
function RandStr(length, seed, lower, upper, num, symb) {
|
|
let charset = ''
|
|
|
|
if(lower) charset += charLowercase
|
|
if(upper) charset += charUppercase
|
|
if(num) charset += charNum
|
|
if(symb) charset += charSymbol
|
|
|
|
let result = ''
|
|
for(let i = 0; i < length; i++) {
|
|
result += charset[Rand(seed, i, charset.length)]
|
|
}
|
|
return result
|
|
}
|
|
|
|
function Rand(state1, state2, limit){
|
|
var mod1=4294967087
|
|
var mul1=65539
|
|
var mod2=4294965887
|
|
var mul2=65537
|
|
if(typeof state1!="number"){
|
|
state1=+new Date()
|
|
}
|
|
if(typeof state2!="number"){
|
|
state2=state1
|
|
}
|
|
state1=state1%(mod1-1)+1
|
|
state2=state2%(mod2-1)+1
|
|
state1=(state1*mul1)%mod1
|
|
state2=(state2*mul2)%mod2
|
|
if(state1<limit && state2<limit && state1<mod1%limit && state2<mod2%limit){
|
|
return random(limit)
|
|
}
|
|
return (state1+state2)%limit
|
|
}
|
|
|
|
function copyToClipboard(str){
|
|
if (navigator && navigator.clipboard && navigator.clipboard.writeText)
|
|
return navigator.clipboard.writeText(str);
|
|
return Promise.reject('The Clipboard API is not available.');
|
|
};
|
|
|
|
function saveConf() {
|
|
conf.push({
|
|
"site": getEl("site").value,
|
|
"user": getEl("username").value,
|
|
"length": getEl("length").value,
|
|
"lower": getEl("incLowercase").checked,
|
|
"upper": getEl("incUppercase").checked,
|
|
"number": getEl("incNumber").checked,
|
|
"symbol": getEl("incSymbol").checked
|
|
})
|
|
|
|
const link = document.createElement("a");
|
|
const content = JSON.stringify(conf);
|
|
const file = new Blob([content], { type: 'text/plain' });
|
|
link.href = URL.createObjectURL(file);
|
|
link.download = "data.json";
|
|
link.click();
|
|
URL.revokeObjectURL(link.href);
|
|
}
|
|
|
|
function getEl(str){
|
|
return document.getElementById(str)
|
|
}
|
|
|
|
</script>
|
|
</body> |