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'])
|
||||
def do_hash():
|
||||
data = request.get_json() or {}
|
||||
username = data.get('username', '')
|
||||
password = data.get('password', '')
|
||||
salt = data.get('salt', '')
|
||||
algorithm = data.get('algorithm', 'sha512')
|
||||
@@ -52,6 +53,8 @@ def do_hash():
|
||||
abort(400, f'Password must be at least {MIN_LEN} characters')
|
||||
|
||||
if algorithm == 'argon2_copyparty':
|
||||
if (username == '' or username == None):
|
||||
abort(400, 'Please type your username.')
|
||||
|
||||
specified_salt = 'LVZ1TJMdAIdLyBla6nWDexFt'
|
||||
b_pass = password.encode('utf-8')
|
||||
@@ -69,7 +72,7 @@ def do_hash():
|
||||
)
|
||||
|
||||
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})
|
||||
|
||||
|
||||
@@ -40,7 +40,8 @@ button:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
button:disabled {
|
||||
button:disabled,
|
||||
input:disabled {
|
||||
background: #666666;
|
||||
color: #aaaaaa;
|
||||
cursor: not-allowed;
|
||||
|
||||
@@ -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)
|
||||
});
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
</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">
|
||||
<button id="hashBtn">Compute hash</button>
|
||||
|
||||
Reference in New Issue
Block a user