change IPs in code
This commit is contained in:
12
api/app.py
12
api/app.py
@ -27,9 +27,11 @@ password_types = [
|
||||
#################################################
|
||||
# Hash Record Functions
|
||||
#################################################
|
||||
# Create the file if it doesn’t exist
|
||||
if not HASH_FILE.exists():
|
||||
# Nothing to load – create an empty file for future use
|
||||
HASH_FILE.touch(exist_ok=True)
|
||||
|
||||
# Read the hashes
|
||||
try:
|
||||
with HASH_FILE.open("r", encoding="utf-8") as fh:
|
||||
password_hashes = {line.strip() for line in fh if line.strip()}
|
||||
@ -125,7 +127,7 @@ def get_password():
|
||||
"password_types": password_types
|
||||
}), 404 # 404 Not Found
|
||||
|
||||
# Success – return the password
|
||||
# Success - return the password
|
||||
return jsonify({
|
||||
"password": get_password_by_index(index)
|
||||
}), 200
|
||||
@ -151,7 +153,7 @@ def verbose_password():
|
||||
"error": f"Index {index} is out of bounds (0 ≤ index < {len(password_types)})",
|
||||
"password_types": password_types
|
||||
}), 404 # 404 Not Found
|
||||
# Success – return the result
|
||||
# Success - return the result
|
||||
result = {
|
||||
"password": get_password_by_index(index),
|
||||
"descriptor": password_function_descriptor[password_types[index]],
|
||||
@ -166,7 +168,7 @@ def custom_password():
|
||||
|
||||
payload = request.get_json()
|
||||
|
||||
# Basic presence check – you can relax this if you want defaults
|
||||
# Basic presence check - you can relax this if you want defaults
|
||||
required_keys = {"w_min", "w_max", "w_count", "s_char", "num_len"}
|
||||
missing = required_keys - payload.keys()
|
||||
if missing:
|
||||
@ -411,7 +413,7 @@ def check_and_add_hash(password: str) -> bool:
|
||||
hash_value = sha256_hex(password)
|
||||
if hash_value in password_hashes:
|
||||
return False
|
||||
# Hash was missing – add it and report that it was newly inserted.
|
||||
# Hash was missing - add it and report that it was newly inserted.
|
||||
password_hashes.add(hash_value)
|
||||
save_hashes()
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user