lewiswatson commited on
Commit
44a69a7
·
verified ·
1 Parent(s): 82f2823

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -8
app.py CHANGED
@@ -15,13 +15,13 @@ def _key_and_nonce():
15
  img_bytes = (ASSET_IMG.read_bytes() if ASSET_IMG.exists() else b"")
16
  key = hashlib.sha256(img_bytes).digest() # 32 bytes (AES-256)
17
 
18
- # Nonce (8 bytes)
19
  rl = ""
20
  if REQUIREMENTS.exists():
21
  with REQUIREMENTS.open("r", encoding="utf-8", errors="ignore") as f:
22
  rl = (f.readline() or "").strip()
23
  nonce_src = hashlib.sha1(rl.encode("utf-8")).digest()
24
- nonce = nonce_src[:8] if nonce_src else b"\x00"*8
25
 
26
  return key, nonce
27
 
@@ -50,18 +50,36 @@ def verify(candidate: str):
50
  return ("✅ Correct.", flag)
51
  return ("❌ Incorrect.", "")
52
 
53
- with gr.Blocks(title="ENUSEC Freshers – Decrypter 2025") as demo:
54
- gr.Markdown(
55
- """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  # Decrypter 2025
57
- Click **Get Encrypted Blob** to receive a Base64 string.
58
  Submit the flag when you have it.
59
- """
60
- )
 
 
 
61
  b = gr.Button("Get Encrypted Blob")
62
  blob = gr.Textbox(label="Ciphertext (Base64)", interactive=False)
63
  b.click(get_ciphertext, None, blob)
64
 
 
65
  gr.Markdown("## Submit Flag")
66
  guess = gr.Textbox(label="freshers{...}")
67
  submit = gr.Button("Submit")
 
15
  img_bytes = (ASSET_IMG.read_bytes() if ASSET_IMG.exists() else b"")
16
  key = hashlib.sha256(img_bytes).digest() # 32 bytes (AES-256)
17
 
18
+ # Nonce (8 bytes) derived from first line of requirements.txt
19
  rl = ""
20
  if REQUIREMENTS.exists():
21
  with REQUIREMENTS.open("r", encoding="utf-8", errors="ignore") as f:
22
  rl = (f.readline() or "").strip()
23
  nonce_src = hashlib.sha1(rl.encode("utf-8")).digest()
24
+ nonce = nonce_src[:8] if nonce_src else b"\x00" * 8
25
 
26
  return key, nonce
27
 
 
50
  return ("✅ Correct.", flag)
51
  return ("❌ Incorrect.", "")
52
 
53
+ custom_css = """
54
+ #hero { display: flex; gap: 16px; align-items: center; }
55
+ #hero .title h1 { margin: 0; }
56
+ """
57
+
58
+ with gr.Blocks(title="ENUSEC Freshers – Decrypter 2025", css=custom_css) as demo:
59
+ # Hero row with mascot + title
60
+ with gr.Row(elem_id="hero"):
61
+ gr.Image(
62
+ value=str(ASSET_IMG) if ASSET_IMG.exists() else None,
63
+ show_label=False,
64
+ interactive=False,
65
+ height=160,
66
+ visible=ASSET_IMG.exists()
67
+ )
68
+ gr.Markdown(
69
+ """
70
  # Decrypter 2025
71
+ Click **Get Encrypted Blob** to receive a Base64 string.
72
  Submit the flag when you have it.
73
+ """,
74
+ elem_classes=["title"]
75
+ )
76
+
77
+ # Ciphertext section
78
  b = gr.Button("Get Encrypted Blob")
79
  blob = gr.Textbox(label="Ciphertext (Base64)", interactive=False)
80
  b.click(get_ciphertext, None, blob)
81
 
82
+ # Submission section
83
  gr.Markdown("## Submit Flag")
84
  guess = gr.Textbox(label="freshers{...}")
85
  submit = gr.Button("Submit")