sprev21 commited on
Commit
cd13322
·
verified ·
1 Parent(s): e03f27a

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -0
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py
2
+
3
+ import gradio as gr
4
+ import string
5
+
6
+ def caesar_brute_force(ciphertext: str):
7
+ ciphertext = ciphertext.strip()
8
+ if not ciphertext:
9
+ return "Please enter some ciphertext."
10
+
11
+ alphabet = string.ascii_lowercase
12
+ results = []
13
+
14
+ for shift in range(1, 26): # 25 possible Caesar shifts
15
+ decrypted = ''
16
+ for char in ciphertext:
17
+ if char.lower() in alphabet:
18
+ idx = (alphabet.index(char.lower()) - shift) % 26
19
+ new_char = alphabet[idx]
20
+ decrypted += new_char.upper() if char.isupper() else new_char
21
+ else:
22
+ decrypted += char
23
+ results.append(f"Shift {shift}: {decrypted}")
24
+
25
+ return "\n\n".join(results)
26
+
27
+ iface = gr.Interface(
28
+ fn=caesar_brute_force,
29
+ inputs=gr.Textbox(lines=4, label="Enter Caesar Cipher Text"),
30
+ outputs="text",
31
+ title="🔓 Caesar Cipher Brute-Force Analyzer",
32
+ description="Try all 25 Caesar cipher shifts to decrypt a message. Look for the correct one based on the result."
33
+ )
34
+
35
+ iface.launch()