Updated files related to copyparty's argon2
This commit is contained in:
19
app.py
19
app.py
@@ -47,18 +47,15 @@ def do_hash():
|
|||||||
|
|
||||||
if not isinstance(password, str) or not isinstance(salt, str):
|
if not isinstance(password, str) or not isinstance(salt, str):
|
||||||
abort(400, 'Invalid input')
|
abort(400, 'Invalid input')
|
||||||
|
|
||||||
if len(password) < MIN_LEN:
|
if len(password) < MIN_LEN:
|
||||||
abort(400, f'Password must be at least {MIN_LEN} characters')
|
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':
|
if algorithm == 'argon2_copyparty':
|
||||||
|
|
||||||
|
specified_salt = 'LVZ1TJMdAIdLyBla6nWDexFt'
|
||||||
b_pass = password.encode('utf-8')
|
b_pass = password.encode('utf-8')
|
||||||
b_salt = salt.encode('utf-8')
|
b_salt = specified_salt.encode('utf-8')
|
||||||
|
|
||||||
raw_hash_copyparty = hash_secret(
|
raw_hash_copyparty = hash_secret(
|
||||||
secret = b_pass,
|
secret = b_pass,
|
||||||
@@ -76,7 +73,15 @@ def do_hash():
|
|||||||
|
|
||||||
return jsonify({'hash': final_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)
|
prefix = ALG_PREFIX.get(algorithm)
|
||||||
|
|
||||||
if prefix is None:
|
if prefix is None:
|
||||||
abort(400, 'Unsupported algorithm')
|
abort(400, 'Unsupported algorithm')
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,13 @@ button:hover {
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
button:disabled {
|
||||||
|
background: #666666;
|
||||||
|
color: #aaaaaa;
|
||||||
|
cursor: not-allowed;
|
||||||
|
filter: grayscale(1);
|
||||||
|
}
|
||||||
|
|
||||||
.row {
|
.row {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 8px
|
gap: 8px
|
||||||
|
|||||||
@@ -19,6 +19,25 @@ gensaltBtn.addEventListener('click', async () => {
|
|||||||
salt.value = data.salt;
|
salt.value = data.salt;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const updateUI = () => {
|
||||||
|
const isCopyparty = algorithm.value === 'argon2_copyparty';
|
||||||
|
|
||||||
|
salt.disabled = isCopyparty;
|
||||||
|
gensaltBtn.disabled = isCopyparty;
|
||||||
|
|
||||||
|
if (isCopyparty) {
|
||||||
|
salt.value = "LVZ1TJMdAIdLyBla6nWDexFt";
|
||||||
|
salt.style.opacity = "0.5";
|
||||||
|
} else {
|
||||||
|
|
||||||
|
salt.value = "";
|
||||||
|
salt.style.opacity = "";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
algorithm.addEventListener('change', updateUI);
|
||||||
|
window.addEventListener('DOMContentLoaded', updateUI);
|
||||||
|
|
||||||
hashBtn.addEventListener('click', async () => {
|
hashBtn.addEventListener('click', async () => {
|
||||||
const pass = password.value || '';
|
const pass = password.value || '';
|
||||||
const s = salt.value || '';
|
const s = salt.value || '';
|
||||||
@@ -29,10 +48,13 @@ hashBtn.addEventListener('click', async () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (alg !== 'argon2_copyparty') {
|
||||||
if (s.length < MIN_SALT_LEN || s.length > MAX_SALT_LEN) {
|
if (s.length < MIN_SALT_LEN || s.length > MAX_SALT_LEN) {
|
||||||
alert('Salt must be between ' + MIN_SALT_LEN + ' and ' + MAX_SALT_LEN + ' characters');
|
alert('Salt must be between ' + MIN_SALT_LEN + ' and ' + MAX_SALT_LEN + ' characters');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const payload = { password: pass, salt: s, algorithm: alg };
|
const payload = { password: pass, salt: s, algorithm: alg };
|
||||||
const res = await fetch('/hash', {
|
const res = await fetch('/hash', {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
<h2>The Night Club's Hashing Tool</h2>
|
<h2>The Night Club's Hashing Tool</h2>
|
||||||
|
|
||||||
<label for="algorithm">Algorithm</label>
|
<label for="algorithm">Algorithm</label>
|
||||||
<select id="algorithm">
|
<select id="algorithm" onchange="updateUI()">
|
||||||
<option value="sha512">sha512-crypt ($6$)</option>
|
<option value="sha512">sha512-crypt ($6$)</option>
|
||||||
<option value="sha256">sha256-crypt ($5$)</option>
|
<option value="sha256">sha256-crypt ($5$)</option>
|
||||||
<option value="argon2_std">argon2 ($argon2id$)</option>
|
<option value="argon2_std">argon2 ($argon2id$)</option>
|
||||||
|
|||||||
Reference in New Issue
Block a user