tuhbooh commited on
Commit
22f2ea2
·
verified ·
1 Parent(s): cf3f3db

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -55
app.py CHANGED
@@ -26,7 +26,6 @@ def get_file_sha256(file_path):
26
  # --- 2. HÀM THIẾT KẾ CHỨNG CHỈ (BẢN FRIENDLY BY MINH ĐỨC) ---
27
  class T4S_PDF(FPDF):
28
  def header(self):
29
- # Header phong cách hiện đại
30
  self.set_fill_color(44, 62, 80)
31
  self.rect(0, 0, 297, 30, 'F')
32
  self.set_text_color(255, 255, 255)
@@ -47,37 +46,25 @@ class T4S_PDF(FPDF):
47
  def create_detailed_pdf(file_name, sha_hash, password, output_path):
48
  pdf = T4S_PDF(orientation="L", unit="mm", format="A4")
49
  pdf.add_page()
50
-
51
- # 1. THÔNG TIN FILE
52
  pdf.ln(10)
53
  pdf.set_text_color(0, 0, 0)
54
  pdf.set_font("Helvetica", "B", 16)
55
  pdf.cell(0, 10, "1. ĐỐI TƯỢNG ĐÃ ĐƯỢC 'XỬ LÝ'", ln=True)
56
  pdf.set_line_width(0.5); pdf.set_draw_color(44, 62, 80); pdf.line(10, pdf.get_y(), 287, pdf.get_y())
57
-
58
  pdf.ln(5)
59
  pdf.set_font("Helvetica", "", 12)
60
  pdf.cell(40, 10, "Tên file gốc:", 0); pdf.set_font("Helvetica", "B", 12); pdf.cell(0, 10, file_name, ln=True)
61
  pdf.set_font("Helvetica", "I", 10); pdf.set_text_color(100, 100, 100)
62
  pdf.cell(0, 5, "À umm, file của bạn giờ thành bột mì (mã hóa) hết rồi nhé :/", ln=True)
63
-
64
- # 2. CÔNG NGHỆ
65
  pdf.ln(10)
66
  pdf.set_text_color(0, 0, 0)
67
  pdf.set_font("Helvetica", "B", 16)
68
  pdf.cell(0, 10, "2. 'MA THUẬT' ĐẰNG SAU", ln=True)
69
  pdf.set_line_width(0.5); pdf.line(10, pdf.get_y(), 287, pdf.get_y())
70
-
71
  pdf.ln(5)
72
  pdf.set_font("Helvetica", "", 11)
73
- tech_info = (
74
- "- Bam! SHA-512 chạy 10,000 vòng để hacker 'khóc thét'.\n"
75
- "- Vectorized Non-linear: Chế độ xào nấu dữ liệu siêu cấp của Minh Đức.\n"
76
- "- Zero-Knowledge: Mình không giữ khóa của bạn đâu, mất là mình cũng chịu thua!"
77
- )
78
  pdf.multi_cell(0, 7, tech_info)
79
-
80
- # 3. MẬT KHẨU
81
  pdf.ln(10)
82
  pdf.set_fill_color(240, 240, 240)
83
  pdf.rect(10, pdf.get_y(), 277, 30, 'F')
@@ -86,26 +73,6 @@ def create_detailed_pdf(file_name, sha_hash, password, output_path):
86
  pdf.cell(0, 5, "MẬT KHẨU ĐÂY NÈ (CẤM QUÊN - QUÊN LÀ NHỊN):", ln=True, align="C")
87
  pdf.set_font("Courier", "B", 20)
88
  pdf.cell(0, 15, f">> {password} <<", ln=True, align="C")
89
-
90
- # 4. LỜI NHẮC NHỞ
91
- pdf.ln(15)
92
- pdf.set_text_color(44, 62, 80)
93
- pdf.set_font("Helvetica", "B", 12)
94
- pdf.cell(0, 10, "MẤY CÁI NÀY QUAN TRỌNG NÈ:", ln=True)
95
- pdf.set_font("Helvetica", "", 10)
96
- pdf.multi_cell(0, 6, (
97
- "1. Cái file PDF này là tấm vé duy nhất để bạn tìm lại dữ liệu. Giữ cho kỹ nha!\n"
98
- "2. File .impossible bị khóa bằng toán học rồi, siêu máy tính giải cũng mất vài thế kỷ.\n"
99
- "3. Nên cất chứng chỉ này vào ổ cứng rời hoặc in ra rồi giấu dưới gối cho chắc."
100
- ))
101
-
102
- # Dấu ấn riêng
103
- pdf.set_font("Helvetica", "B", 40)
104
- pdf.set_text_color(200, 200, 200)
105
- pdf.rotate(20, 200, 150)
106
- pdf.text(170, 185, "MINH DUC SECURED")
107
- pdf.rotate(0)
108
-
109
  pdf.output(output_path)
110
  return output_path
111
 
@@ -116,14 +83,13 @@ def stretch_key(password):
116
  return key[:32]
117
 
118
  def process_file(file, password, mode, progress=gr.Progress()):
119
- if not encrypt_fn: return None, "❌ Lỗi Secret ES! Kiểm tra biến môi trường."
120
- if not password: return None, "⚠️ Nhập mật khẩu đã rồi tính tiếp bạn ơi!"
121
 
122
  master_key = np.frombuffer(stretch_key(password), dtype=np.uint8)
123
  input_path = file.name
124
  original_name = os.path.basename(input_path)
125
  is_encrypt = (mode == "Mã hóa")
126
-
127
  output_name = original_name + ".impossible" if is_encrypt else (original_name.replace(".impossible", "") if original_name.endswith(".impossible") else "rebuilt_" + original_name)
128
  output_path = os.path.join(os.path.dirname(input_path), output_name)
129
  file_size = os.path.getsize(input_path)
@@ -147,30 +113,30 @@ def process_file(file, password, mode, progress=gr.Progress()):
147
  if is_encrypt:
148
  pdf_path = os.path.join(os.path.dirname(input_path), f"Audit_{original_name}.pdf")
149
  create_detailed_pdf(original_name, file_hash, password, pdf_path)
150
- return [output_path, pdf_path], "✅ Xong! File đã 'hóa vàng' và có luôn hồ sơ bảo mật nhé!"
151
 
152
- return [output_path], "✅ Giải mã thành công! Chào mừng file đã quay trở lại."
153
- except Exception as e:
154
- return None, f"❌ Có biến rồi: {str(e)}"
155
 
156
- # --- 4. GIAO DIỆN GRADIO ---
157
  with gr.Blocks(theme=gr.themes.Soft(), title="Titanium4S Vault") as demo:
158
- gr.Markdown("""
159
- # 🛡️ Titanium4S - Ultimate Audit Edition
160
- ### Hệ thống bảo mật "Made by Minh Đức" - An toàn tuyệt đối, thân thiện tối đa.
161
- """)
162
  with gr.Row():
163
  with gr.Column():
164
- inp_file = gr.File(label="Kéo file vào đây nè")
165
- inp_pass = gr.Textbox(label="Mật khẩu mật (Đừng để ai thấy nha)", type="password", placeholder="Nhập pass tại đây...")
166
- inp_mode = gr.Radio([" hóa", "Giải mã"], label="Bạn muốn làm gì?", value=" hóa")
167
- btn = gr.Button("KÍCH HOẠT GIAO THỨC", variant="primary")
 
 
168
  with gr.Column():
169
- out_files = gr.File(label="Kết quả thu được", file_count="multiple")
170
- status = gr.Textbox(label="Trạng thái hệ thống", interactive=False)
171
-
 
172
  gr.Markdown("---")
173
- gr.Markdown("© 2026 Titanium4S Project | Liên hệ: truonghoangminhduc123@gmail.com | Donate: dub.sh/donatemepls")
174
 
175
  if __name__ == "__main__":
176
- demo.queue().launch()
 
26
  # --- 2. HÀM THIẾT KẾ CHỨNG CHỈ (BẢN FRIENDLY BY MINH ĐỨC) ---
27
  class T4S_PDF(FPDF):
28
  def header(self):
 
29
  self.set_fill_color(44, 62, 80)
30
  self.rect(0, 0, 297, 30, 'F')
31
  self.set_text_color(255, 255, 255)
 
46
  def create_detailed_pdf(file_name, sha_hash, password, output_path):
47
  pdf = T4S_PDF(orientation="L", unit="mm", format="A4")
48
  pdf.add_page()
 
 
49
  pdf.ln(10)
50
  pdf.set_text_color(0, 0, 0)
51
  pdf.set_font("Helvetica", "B", 16)
52
  pdf.cell(0, 10, "1. ĐỐI TƯỢNG ĐÃ ĐƯỢC 'XỬ LÝ'", ln=True)
53
  pdf.set_line_width(0.5); pdf.set_draw_color(44, 62, 80); pdf.line(10, pdf.get_y(), 287, pdf.get_y())
 
54
  pdf.ln(5)
55
  pdf.set_font("Helvetica", "", 12)
56
  pdf.cell(40, 10, "Tên file gốc:", 0); pdf.set_font("Helvetica", "B", 12); pdf.cell(0, 10, file_name, ln=True)
57
  pdf.set_font("Helvetica", "I", 10); pdf.set_text_color(100, 100, 100)
58
  pdf.cell(0, 5, "À umm, file của bạn giờ thành bột mì (mã hóa) hết rồi nhé :/", ln=True)
 
 
59
  pdf.ln(10)
60
  pdf.set_text_color(0, 0, 0)
61
  pdf.set_font("Helvetica", "B", 16)
62
  pdf.cell(0, 10, "2. 'MA THUẬT' ĐẰNG SAU", ln=True)
63
  pdf.set_line_width(0.5); pdf.line(10, pdf.get_y(), 287, pdf.get_y())
 
64
  pdf.ln(5)
65
  pdf.set_font("Helvetica", "", 11)
66
+ tech_info = "- Bam! SHA-512 chạy 10,000 vòng.\n- Vectorized Non-linear Logic.\n- Zero-Knowledge: Không lưu khóa."
 
 
 
 
67
  pdf.multi_cell(0, 7, tech_info)
 
 
68
  pdf.ln(10)
69
  pdf.set_fill_color(240, 240, 240)
70
  pdf.rect(10, pdf.get_y(), 277, 30, 'F')
 
73
  pdf.cell(0, 5, "MẬT KHẨU ĐÂY NÈ (CẤM QUÊN - QUÊN LÀ NHỊN):", ln=True, align="C")
74
  pdf.set_font("Courier", "B", 20)
75
  pdf.cell(0, 15, f">> {password} <<", ln=True, align="C")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  pdf.output(output_path)
77
  return output_path
78
 
 
83
  return key[:32]
84
 
85
  def process_file(file, password, mode, progress=gr.Progress()):
86
+ if not encrypt_fn: return None, "❌ Lỗi Secret ES!"
87
+ if not password: return None, "⚠️ Nhập mật khẩu đi bạn ơi!"
88
 
89
  master_key = np.frombuffer(stretch_key(password), dtype=np.uint8)
90
  input_path = file.name
91
  original_name = os.path.basename(input_path)
92
  is_encrypt = (mode == "Mã hóa")
 
93
  output_name = original_name + ".impossible" if is_encrypt else (original_name.replace(".impossible", "") if original_name.endswith(".impossible") else "rebuilt_" + original_name)
94
  output_path = os.path.join(os.path.dirname(input_path), output_name)
95
  file_size = os.path.getsize(input_path)
 
113
  if is_encrypt:
114
  pdf_path = os.path.join(os.path.dirname(input_path), f"Audit_{original_name}.pdf")
115
  create_detailed_pdf(original_name, file_hash, password, pdf_path)
116
+ return [output_path, pdf_path], "✅ Đã xong! Check vùng kết quả nhé."
117
 
118
+ return [output_path], "✅ Giải mã thành công!"
119
+ except Exception as e: return None, f"❌ Lỗi: {str(e)}"
 
120
 
121
+ # --- 4. GIAO DIỆN GRADIO (FIXED) ---
122
  with gr.Blocks(theme=gr.themes.Soft(), title="Titanium4S Vault") as demo:
123
+ gr.Markdown("# 🛡️ Titanium4S - Ultimate Audit Edition")
124
+
 
 
125
  with gr.Row():
126
  with gr.Column():
127
+ # ĐÂY VÙNG UPLOAD DUY NHẤT
128
+ inp_file = gr.File(label="Kéo file vào đây", file_count="single")
129
+ inp_pass = gr.Textbox(label="Mật khẩu", type="password", placeholder="Nhập pass...")
130
+ inp_mode = gr.Radio([" hóa", "Giải "], label="Chế độ", value="Mã hóa")
131
+ btn = gr.Button("KÍCH HOẠT", variant="primary")
132
+
133
  with gr.Column():
134
+ # ĐÂY LÀ VÙNG KẾT QUẢ (Đã tắt tính năng tương tác để không bị nhầm là ô upload)
135
+ out_files = gr.File(label="File nhận lại", interactive=False)
136
+ status = gr.Textbox(label="Thông báo", interactive=False)
137
+
138
  gr.Markdown("---")
139
+ gr.Markdown("© 2026 Titanium4S Project | Liên hệ: truonghoangminhduc123@gmail.com")
140
 
141
  if __name__ == "__main__":
142
+ demo.launch()