1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642
| import tkinter as tk from tkinter import messagebox, ttk import os import sys import threading import time import cv2 from PIL import Image, ImageTk
from xor1 import decrypt as xor_decrypt from rc4 import decrypt as rc4_decrypt from tea import decrypt1 as tea_decrypt from xtea import decrypt1 as xtea_decrypt from xxtea import decrypt as xxtea_decrypt
class UIBuilder: """UI组件构建工具类,用于创建统一风格的UI元素"""
@staticmethod def create_title(parent, text, font_size=24, emoji="", bg="#1a1a2e"): """创建带表情符号的标题标签""" title = tk.Label( parent, text=f"{emoji} {text} {emoji}", font=("微软雅黑", font_size, "bold"), bg=bg, fg="white" ) return title
@staticmethod def create_button(parent, text, command, bg="#4ECDC4", font_size=12, emoji="", bg_hover="#3A9DA2"): """创建带悬停效果的按钮"""
def on_enter(e): btn.config(bg=bg_hover)
def on_leave(e): btn.config(bg=bg)
btn = tk.Button( parent, text=f"{emoji} {text} {emoji}" if emoji else text, command=command, font=("微软雅黑", font_size, "bold"), bg=bg, fg="white", relief="flat", bd=0 ) btn.bind("<Enter>", on_enter) btn.bind("<Leave>", on_leave) return btn
@staticmethod def create_label(parent, text, font_size=12, fg="white", bg="#1a1a2e"): """创建统一风格的标签""" label = tk.Label( parent, text=text, font=("微软雅黑", font_size), fg=fg, bg=bg ) return label
@staticmethod def create_algorithm_info(parent, algorithm): """生成算法说明文本""" info_texts = { "xor": " XOR通过将密文与密钥进行异或操作来还原明文。\n" "特点:速度快,适用于简单加密场景,但安全性较低。", "rc4": "RC4是一种流加密算法,通过密钥生成伪随机字节流,与密文异或得到明文。\n" " 特点:效率高,常用于网络数据加密,但存在安全漏洞需注意。", "tea": "TEA是一种分组加密算法,使用64位分组和128位密钥。\n" " 特点:结构简单,安全性较高,适用于资源受限环境。", "xtea": "XTEA是TEA的扩展版本,改进了加密函数和密钥调度算法。\n" " 特点:比TEA更抗密码分析,保持了算法简洁性。", "xxtea": "XXTEA是另一种TEA扩展,进一步优化了加密强度和性能。\n" " 特点:安全性高,适用于需要可靠加密的场景。" } info = tk.Label( parent, text=info_texts.get(algorithm, "暂无算法说明"), font=("微软雅黑", 10), fg="#CCCCCC", bg="#1a1a2e", justify=tk.LEFT, wraplength=480 ) return info
class VideoBackground: """视频背景播放器(增强版,强制使用视频背景)"""
def __init__(self, parent, video_path, width=800, height=600): self.parent = parent self.width = width self.height = height self.video_path = os.path.abspath(video_path) self.cap = None self.video_label = tk.Label(parent, bg="black") self.video_label.place(x=0, y=0, relwidth=1, relheight=1) self.stop_flag = False self.thread = None self.running = True self.error_count = 0
self._init_video(force=True)
def _init_video(self, force=False): """初始化视频,支持强制重试""" if not os.path.exists(self.video_path): self._show_error(f"⚠️ 视频文件不存在:{self.video_path}") self._create_error_overlay("视频文件缺失") return
try: self.cap = cv2.VideoCapture(self.video_path) if not self.cap.isOpened(): raise RuntimeError(f"无法打开视频文件:{self.video_path}")
self.fps = self.cap.get(cv2.CAP_PROP_FPS) or 30 self.start_playback() self.error_count = 0
except Exception as e: self.error_count += 1 self._show_error(f"⚠️ 视频打开错误(尝试 {self.error_count}/5):{str(e)}")
self._create_error_overlay(f"视频加载失败 {self.error_count}/5\n正在重试...")
if self.error_count <= 5 and force: self.parent.after(3000, self._init_video) else: self._show_error("⚠️ 视频加载失败,使用默认背景", critical=True)
def _show_error(self, msg, critical=False): """显示错误信息""" if DEBUG: print(msg) if critical: messagebox.showerror("视频初始化失败", msg)
def _create_error_overlay(self, text): """创建错误提示覆盖层(半透明)""" for widget in self.parent.winfo_children(): if isinstance(widget, tk.Canvas) and widget._name.startswith("error_overlay"): widget.destroy()
overlay = tk.Canvas( self.parent, width=self.width, height=self.height, bg="black", bd=0, highlightthickness=0 ) overlay.place(x=0, y=0) overlay._name = "error_overlay"
overlay.create_rectangle( 0, 0, self.width, self.height, fill="black", stipple="gray50" )
overlay.create_text( self.width / 2, self.height / 2, text=text, fill="white", font=("微软雅黑", 14, "bold") )
def start_playback(self): """启动视频播放""" if self.cap and not self.thread: self.stop_flag = False self.thread = threading.Thread( target=self._update_video, daemon=True ) self.thread.start()
def stop_playback(self): """停止视频播放并释放资源""" self.stop_flag = True self.running = False if self.thread and self.thread.is_alive(): self.thread.join(timeout=3) if self.cap: self.cap.release() self.cap = None if DEBUG: print("🎥 视频播放已停止")
def _update_video(self): """视频帧更新循环""" while self.running and not self.stop_flag: try: if not self.cap or not self.cap.isOpened(): self._init_video() time.sleep(1) continue
ret, frame = self.cap.read() if not ret: self.cap.set(cv2.CAP_PROP_POS_FRAMES, 0) continue
frame = cv2.resize(frame, (self.width, self.height)) frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) img = Image.fromarray(frame) imgtk = ImageTk.PhotoImage(image=img)
self.video_label.config(image=imgtk) self.video_label.image = imgtk time.sleep(1.0 / self.fps)
except Exception as e: if DEBUG: print(f"⚠️ 视频处理错误:{str(e)}") time.sleep(1)
class DecryptApp: def __init__(self, root): self.root = root self.root.title("✨ linkpwn的解密工具 ✨") self.root.geometry("800x600") self.root.resizable(False, False)
try: root.iconbitmap("linkpwn.ico") except: if DEBUG: print("⚠️ 图标加载失败,使用默认图标")
video_path = "富士山的星空.mp4" self.video_bg = VideoBackground(root, video_path)
self.create_welcome_screen() self.create_status_bar()
self.root.protocol("WM_DELETE_WINDOW", self.on_close)
def create_welcome_screen(self): """创建欢迎界面(仅保留视频背景上的UI元素)""" title = UIBuilder.create_title( self.root, "欢迎使用linkpwn的解密工具", font_size=36, emoji="✨", bg=None ) title.configure(fg="#5dade2") title.place(relx=0.5, rely=0.3, anchor=tk.CENTER)
enter_btn = UIBuilder.create_button( self.root, "进入解密工具", self.open_algorithm_selector, bg="#FF6B6B", font_size=18, emoji="🔓", bg_hover="#FF4D4F" ) enter_btn.place(relx=0.5, rely=0.5, anchor=tk.CENTER)
copyright_text = UIBuilder.create_label( self.root, "© 2025 linkpwn. 保留所有权利.", font_size=10, fg="#999999", bg=None ) copyright_text.place(relx=0.5, rely=0.95, anchor=tk.CENTER)
def open_algorithm_selector(self): """打开算法选择窗口(优化背景显示)""" self.algorithm_window = tk.Toplevel(self.root) self.algorithm_window.title("💡 选择解密算法") self.algorithm_window.geometry("600x400") self.algorithm_window.resizable(False, False) self.algorithm_window.transient(self.root)
bg = tk.Canvas( self.algorithm_window, width=600, height=400, bg="black", highlightthickness=0 ) bg.pack(fill="both", expand=True)
title = UIBuilder.create_title( self.algorithm_window, "选择解密算法", font_size=24, emoji="🔐" ) title.place(relx=0.5, y=30, anchor=tk.CENTER)
sep = tk.Frame(self.algorithm_window, height=2, bg="#4ECDC4") sep.place(x=50, y=70, width=500)
algorithms = [ ("xor", "❌ XOR解密"), ("rc4", "🔒 RC4解密"), ("tea", "🍵 TEA解密"), ("xtea", "🍵 XTEA解密"), ("xxtea", "🍵 XXTEA解密"), ]
for idx, (alg, text) in enumerate(algorithms): btn = tk.Button( self.algorithm_window, text=text, font=("微软雅黑", 14, "bold"), bg="#4ECDC4", fg="white", relief="flat", command=lambda a=alg: self.open_decrypt_window(a) ) x = 100 if idx % 2 == 0 else 350 y = 120 + (idx // 2) * 80 btn.place(x=x, y=y, width=200, height=60)
def open_decrypt_window(self, algorithm): """打开解密窗口(优化背景显示)""" if hasattr(self, 'decrypt_window') and self.decrypt_window.winfo_exists(): self.decrypt_window.destroy()
self.decrypt_window = tk.Toplevel(self.root) self.decrypt_window.title(f"💬 {self.get_algorithm_name(algorithm)}解密面板") self.decrypt_window.geometry("600x450") self.decrypt_window.resizable(False, False) self.decrypt_window.transient(self.root)
panel = tk.Canvas( self.decrypt_window, width=600, height=450, bg="black", highlightthickness=0, bd=0, relief="flat" ) panel.pack(fill="both", expand=True)
title = UIBuilder.create_title( panel, f"{self.get_algorithm_name(algorithm)}解密工具", font_size=24, bg="black" ) title.place(relx=0.5, y=30, anchor=tk.CENTER)
sep = tk.Frame(panel, height=2, bg="#4ECDC4") sep.place(x=50, y=70, width=500)
info = UIBuilder.create_algorithm_info(panel, algorithm) info.place(x=50, y=90, width=500)
cipher_frame = tk.Frame(panel, bg="#1a1a2e") cipher_frame.place(x=50, y=130, width=500, height=100)
cipher_label = UIBuilder.create_label(cipher_frame, "密文:", font_size=12) cipher_label.pack(anchor="w", pady=(0, 5))
self.cipher_entry = tk.Text( cipher_frame, width=58, height=3, font=("Consolas", 12), bg="#2a2a3e", fg="white", insertbackground="white", relief="flat", padx=10, pady=5 ) self.cipher_entry.pack(fill="x") self.cipher_entry.insert("1.0", self.get_default_ciphertext(algorithm))
key_frame = tk.Frame(panel, bg="#1a1a2e") key_frame.place(x=50, y=250, width=500, height=80)
key_label = UIBuilder.create_label(key_frame, "密钥:", font_size=12) key_label.pack(anchor="w", pady=(0, 5))
self.key_entry = tk.Entry( key_frame, width=58, font=("Consolas", 12), bg="#2a2a3e", fg="white", insertbackground="white", relief="flat" ) self.key_entry.pack(fill="x") self.key_entry.insert(0, self.get_default_key(algorithm))
btn_frame = tk.Frame(panel, bg="#1a1a2e") btn_frame.place(x=50, y=340, width=500, height=40)
decrypt_btn = UIBuilder.create_button( btn_frame, "开始解密", lambda: self.perform_decryption(algorithm), bg="#FF6B6B", font_size=14, emoji="🔓" ) decrypt_btn.pack(side="left", padx=(150, 0))
back_btn = UIBuilder.create_button( btn_frame, "返回", self.decrypt_window.destroy, bg="#666666", font_size=10, emoji="◀" ) back_btn.pack(side="right", padx=(0, 20))
hint = UIBuilder.create_label( panel, "💡 提示: 输入密文和密钥后点击解密按钮", font_size=10, fg="#999999" ) hint.place(x=50, y=400, width=500)
def get_algorithm_name(self, algorithm): """获取算法名称""" names = { "xor": "XOR", "rc4": "RC4", "tea": "TEA", "xtea": "XTEA", "xxtea": "XXTEA" } return names.get(algorithm, algorithm.upper())
def get_default_ciphertext(self, algorithm): """获取默认密文""" defaults = { "xor": "1a2b3c4d5e6f", "rc4": "730e7d1c4a1e", "tea": "0123456789abcdef", "xtea": "0123456789abcdef", "xxtea": "0123456789abcdef" } return defaults.get(algorithm, "")
def get_default_key(self, algorithm): """获取默认密钥""" defaults = { "xor": "secret", "rc4": "key12345", "tea": "1234567890123456", "xtea": "1234567890123456", "xxtea": "1234567890123456" } return defaults.get(algorithm, "")
def create_status_bar(self): """创建状态栏""" self.status = tk.Label( self.root, text="✨ 就绪 | linkpwn的解密工具 v1.0 | 安全解密 ✨", bd=1, relief=tk.SUNKEN, anchor=tk.W, font=("微软雅黑", 9), fg="#CCCCCC", bg="#1a1a2e" ) self.status.pack(side=tk.BOTTOM, fill=tk.X)
def perform_decryption(self, algorithm): """执行解密操作""" ciphertext = self.cipher_entry.get("1.0", tk.END).strip() key = self.key_entry.get().strip()
if not ciphertext: self.status.config(text="🛑 错误: 密文不能为空") messagebox.showerror("😢 错误", "密文不能为空哦!") return
if not key: self.status.config(text="🛑 错误: 密钥不能为空") messagebox.showerror("😢 错误", "密钥不能为空哦!") return
self.status.config(text=f"🔄 使用{self.get_algorithm_name(algorithm)}解密中...") threading.Thread(target=self._perform_decryption_thread, args=(ciphertext, key, algorithm), daemon=True).start()
def _perform_decryption_thread(self, ciphertext, key, algorithm): """在单独的线程中执行解密操作""" try: if algorithm == "xor": result = xor_decrypt(ciphertext, key) elif algorithm == "rc4": result = rc4_decrypt(ciphertext, key) elif algorithm == "tea": result = tea_decrypt(ciphertext, key) elif algorithm == "xtea": result = xtea_decrypt(ciphertext, key) elif algorithm == "xxtea": result = xxtea_decrypt(ciphertext, key) else: result = f"🛑 不支持的算法: {algorithm}"
self.root.after(0, self._update_decryption_result, result) except Exception as e: error_msg = f"🛑 解密过程中发生错误: {str(e)}" self.root.after(0, self._update_decryption_error, error_msg)
def _update_decryption_result(self, result): """更新解密结果""" if "错误" in result or "Error" in result: self.status.config(text=f"😢 解密失败: {result}") messagebox.showerror("😢 解密失败", result) else: self.status.config(text="🎉 解密成功!") self.show_result(result)
def _update_decryption_error(self, error_msg): """更新解密错误""" self.status.config(text=error_msg) messagebox.showerror("😢 错误", error_msg)
def show_result(self, plaintext): """显示解密结果窗口(优化背景显示)""" try: result_window = tk.Toplevel(self.decrypt_window) result_window.title("🎁 解密结果") result_window.geometry("500x300") result_window.resizable(False, False)
bg = tk.Canvas(result_window, width=500, height=300, bg="#1a1a2e") bg.pack(fill="both", expand=True)
title = UIBuilder.create_title( bg, "解密成功!", font_size=18, emoji="🎉", bg="#1a1a2e" ) title.place(relx=0.5, y=40, anchor=tk.CENTER)
result_frame = tk.Frame(bg, bg="#2a2a3e", bd=1, relief=tk.SUNKEN) result_frame.place(x=25, y=70, width=450, height=180)
scrollbar = ttk.Scrollbar(result_frame) scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
result_text = tk.Text( result_frame, bg="#2a2a3e", fg="white", font=("Consolas", 11), yscrollcommand=scrollbar.set, wrap=tk.WORD, padx=10, pady=10 ) result_text.pack(fill="both", expand=True) result_text.insert(tk.END, plaintext) result_text.config(state=tk.DISABLED) scrollbar.config(command=result_text.yview)
close_btn = UIBuilder.create_button( bg, "关闭", result_window.destroy, bg="#4ECDC4", font_size=12 ) close_btn.place(relx=0.5, y=260, anchor=tk.CENTER) except Exception as e: messagebox.showerror("😢 错误", f"无法显示结果: {str(e)}")
def on_close(self): """窗口关闭时停止视频播放""" if hasattr(self, 'video_bg') and self.video_bg: self.video_bg.stop_playback() self.root.destroy()
DEBUG = True
def run_app(): """运行应用程序""" root = tk.Tk() if sys.platform in ['win32', 'linux']: root.attributes('-alpha', 0.95) app = DecryptApp(root) root.mainloop()
if __name__ == "__main__": run_app()
|