Added username field for argon2copyparty only
This commit is contained in:
5
app.py
5
app.py
@@ -40,6 +40,7 @@ def gensalt():
|
|||||||
@app.route('/hash', methods=['POST'])
|
@app.route('/hash', methods=['POST'])
|
||||||
def do_hash():
|
def do_hash():
|
||||||
data = request.get_json() or {}
|
data = request.get_json() or {}
|
||||||
|
username = data.get('username', '')
|
||||||
password = data.get('password', '')
|
password = data.get('password', '')
|
||||||
salt = data.get('salt', '')
|
salt = data.get('salt', '')
|
||||||
algorithm = data.get('algorithm', 'sha512')
|
algorithm = data.get('algorithm', 'sha512')
|
||||||
@@ -52,6 +53,8 @@ def do_hash():
|
|||||||
abort(400, f'Password must be at least {MIN_LEN} characters')
|
abort(400, f'Password must be at least {MIN_LEN} characters')
|
||||||
|
|
||||||
if algorithm == 'argon2_copyparty':
|
if algorithm == 'argon2_copyparty':
|
||||||
|
if (username == '' or username == None):
|
||||||
|
abort(400, 'Please type your username.')
|
||||||
|
|
||||||
specified_salt = 'LVZ1TJMdAIdLyBla6nWDexFt'
|
specified_salt = 'LVZ1TJMdAIdLyBla6nWDexFt'
|
||||||
b_pass = password.encode('utf-8')
|
b_pass = password.encode('utf-8')
|
||||||
@@ -69,7 +72,7 @@ def do_hash():
|
|||||||
)
|
)
|
||||||
|
|
||||||
hash_only = raw_hash_copyparty.split(b"$")[-1].decode('utf-8')
|
hash_only = raw_hash_copyparty.split(b"$")[-1].decode('utf-8')
|
||||||
final_hash = "+" + hash_only.replace('/', "_").replace('+', '-')
|
final_hash = username + ":+" + hash_only.replace('/', "_").replace('+', '-')
|
||||||
|
|
||||||
return jsonify({'hash': final_hash})
|
return jsonify({'hash': final_hash})
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,8 @@ button:hover {
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
button:disabled {
|
button:disabled,
|
||||||
|
input:disabled {
|
||||||
background: #666666;
|
background: #666666;
|
||||||
color: #aaaaaa;
|
color: #aaaaaa;
|
||||||
cursor: not-allowed;
|
cursor: not-allowed;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ const hashBtn = document.getElementById('hashBtn');
|
|||||||
const result = document.getElementById('result');
|
const result = document.getElementById('result');
|
||||||
const clearBtn = document.getElementById('clearBtn');
|
const clearBtn = document.getElementById('clearBtn');
|
||||||
const resultBtn = document.getElementById('resultBtn');
|
const resultBtn = document.getElementById('resultBtn');
|
||||||
|
const username = document.getElementById('username');
|
||||||
|
|
||||||
const MIN_PASS_LEN = 16;
|
const MIN_PASS_LEN = 16;
|
||||||
const MIN_SALT_LEN = 8;
|
const MIN_SALT_LEN = 8;
|
||||||
@@ -24,14 +25,15 @@ const updateUI = () => {
|
|||||||
|
|
||||||
salt.disabled = isCopyparty;
|
salt.disabled = isCopyparty;
|
||||||
gensaltBtn.disabled = isCopyparty;
|
gensaltBtn.disabled = isCopyparty;
|
||||||
|
username.disabled = !isCopyparty;
|
||||||
|
|
||||||
if (isCopyparty) {
|
if (isCopyparty) {
|
||||||
salt.value = "LVZ1TJMdAIdLyBla6nWDexFt";
|
salt.value = "LVZ1TJMdAIdLyBla6nWDexFt";
|
||||||
salt.style.opacity = "0.5";
|
salt.style.opacity = "0.5";
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
salt.value = "";
|
salt.value = "";
|
||||||
salt.style.opacity = "";
|
salt.style.opacity = "";
|
||||||
|
username.value = "";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -42,6 +44,7 @@ hashBtn.addEventListener('click', async () => {
|
|||||||
const pass = password.value || '';
|
const pass = password.value || '';
|
||||||
const s = salt.value || '';
|
const s = salt.value || '';
|
||||||
const alg = algorithm.value;
|
const alg = algorithm.value;
|
||||||
|
const usr = username.value || '';
|
||||||
|
|
||||||
if (pass.length < MIN_PASS_LEN) {
|
if (pass.length < MIN_PASS_LEN) {
|
||||||
alert('Password must be at least ' + MIN_PASS_LEN + ' characters');
|
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', {
|
const res = await fetch('/hash', {
|
||||||
method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload)
|
method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload)
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -32,6 +32,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="note">Salt characters limited to <code>./0-9A-Za-z</code>.</div>
|
<div class="note">Salt characters limited to <code>./0-9A-Za-z</code>.</div>
|
||||||
|
|
||||||
|
<label for="username">Username (copyparty only)</label>
|
||||||
|
<input id="username" type="text" placeholder="Enter username">
|
||||||
|
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<button id="hashBtn">Compute hash</button>
|
<button id="hashBtn">Compute hash</button>
|
||||||
|
|||||||
Reference in New Issue
Block a user