sec: CHANGE default pad_id lenghts from 4 to 8 #25

This commit is contained in:
Caffeine Fueled 2026-05-25 01:22:42 +02:00
parent 812f891c8f
commit 44dc0ee6b6
Signed by: cf7
GPG key ID: CA295D643074C68C

9
app.py
View file

@ -28,7 +28,7 @@ rate_limits: dict[str, list] = defaultdict(list)
# Connection tracking: {ip: connection_count}
connections_per_ip: dict[str, int] = defaultdict(int)
def random_id(n: int = 4) -> str:
def random_id(n: int = 8) -> str:
alphabet = string.ascii_lowercase + string.digits
return "".join(secrets.choice(alphabet) for _ in range(n))
@ -242,7 +242,12 @@ HTML = """<!doctype html>
<script>
const $ = s => document.querySelector(s);
const proto = location.protocol === "https:" ? "wss" : "ws";
const rand = () => Math.random().toString(36).slice(2, 6); // 4 chars
const rand = () => {
const arr = new Uint8Array(8);
crypto.getRandomValues(arr);
const a = "abcdefghijklmnopqrstuvwxyz0123456789";
return Array.from(arr, b => a[b % 36]).join("");
};
// Theme
function applyTheme(dark) {