Added username field for argon2copyparty only
This commit is contained in:
@@ -6,6 +6,7 @@ const hashBtn = document.getElementById('hashBtn');
|
||||
const result = document.getElementById('result');
|
||||
const clearBtn = document.getElementById('clearBtn');
|
||||
const resultBtn = document.getElementById('resultBtn');
|
||||
const username = document.getElementById('username');
|
||||
|
||||
const MIN_PASS_LEN = 16;
|
||||
const MIN_SALT_LEN = 8;
|
||||
@@ -24,14 +25,15 @@ const updateUI = () => {
|
||||
|
||||
salt.disabled = isCopyparty;
|
||||
gensaltBtn.disabled = isCopyparty;
|
||||
username.disabled = !isCopyparty;
|
||||
|
||||
if (isCopyparty) {
|
||||
salt.value = "LVZ1TJMdAIdLyBla6nWDexFt";
|
||||
salt.style.opacity = "0.5";
|
||||
} else {
|
||||
|
||||
salt.value = "";
|
||||
salt.style.opacity = "";
|
||||
username.value = "";
|
||||
}
|
||||
};
|
||||
|
||||
@@ -42,6 +44,7 @@ hashBtn.addEventListener('click', async () => {
|
||||
const pass = password.value || '';
|
||||
const s = salt.value || '';
|
||||
const alg = algorithm.value;
|
||||
const usr = username.value || '';
|
||||
|
||||
if (pass.length < MIN_PASS_LEN) {
|
||||
alert('Password must be at least ' + MIN_PASS_LEN + ' characters');
|
||||
@@ -55,8 +58,15 @@ hashBtn.addEventListener('click', async () => {
|
||||
}
|
||||
}
|
||||
|
||||
if (alg == 'argon2_copyparty') {
|
||||
if (usr === '') {
|
||||
alert('Please type your username.');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const payload = { password: pass, salt: s, algorithm: alg };
|
||||
|
||||
const payload = { username: usr, password: pass, salt: s, algorithm: alg };
|
||||
const res = await fetch('/hash', {
|
||||
method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload)
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user