From c7808614b6d62d604fcc510bd3fd41b145cc0bd4 Mon Sep 17 00:00:00 2001 From: eriUNK Date: Sat, 7 Mar 2026 09:51:01 -0300 Subject: [PATCH] Added username field for argon2copyparty only --- app.py | 5 ++++- static/css/style.css | 3 ++- static/js/main.js | 14 ++++++++++++-- templates/index.html | 2 ++ 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/app.py b/app.py index bf20cfd..9800cfd 100644 --- a/app.py +++ b/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}) diff --git a/static/css/style.css b/static/css/style.css index 0f6c880..18289c9 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -40,7 +40,8 @@ button:hover { cursor: pointer; } -button:disabled { +button:disabled, +input:disabled { background: #666666; color: #aaaaaa; cursor: not-allowed; diff --git a/static/js/main.js b/static/js/main.js index a3b9272..6fff579 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -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) }); diff --git a/templates/index.html b/templates/index.html index ae05303..7038c67 100644 --- a/templates/index.html +++ b/templates/index.html @@ -32,6 +32,8 @@
Salt characters limited to ./0-9A-Za-z.
+ +