Updated files related to copyparty's argon2

This commit is contained in:
eriUNK
2026-03-03 17:02:52 -03:00
parent 8338bc3b73
commit ced732876f
4 changed files with 45 additions and 11 deletions

19
app.py
View File

@@ -47,18 +47,15 @@ def do_hash():
if not isinstance(password, str) or not isinstance(salt, str):
abort(400, 'Invalid input')
if len(password) < MIN_LEN:
abort(400, f'Password must be at least {MIN_LEN} characters')
if len(salt) < MIN_SALT_LEN or len(salt) > MAX_SALT_LEN:
abort(400, f'Salt must be between {MIN_SALT_LEN} and {MAX_SALT_LEN} characters')
if algorithm == 'argon2_std':
hashed = ph.hash(password, salt = salt.encode('utf-8'))
return jsonify({'hash': hashed})
if algorithm == 'argon2_copyparty':
specified_salt = 'LVZ1TJMdAIdLyBla6nWDexFt'
b_pass = password.encode('utf-8')
b_salt = salt.encode('utf-8')
b_salt = specified_salt.encode('utf-8')
raw_hash_copyparty = hash_secret(
secret = b_pass,
@@ -76,7 +73,15 @@ def do_hash():
return jsonify({'hash': final_hash})
if len(salt) < MIN_SALT_LEN or len(salt) > MAX_SALT_LEN:
abort(400, f'Salt must be between {MIN_SALT_LEN} and {MAX_SALT_LEN} characters')
if algorithm == 'argon2_std':
hashed = ph.hash(password, salt = salt.encode('utf-8'))
return jsonify({'hash': hashed})
prefix = ALG_PREFIX.get(algorithm)
if prefix is None:
abort(400, 'Unsupported algorithm')