(args)
| 53 | # ── 子命令处理 ───────────────────────────────────────────────────────── |
| 54 | |
| 55 | def cmd_embed(args): |
| 56 | from StegaPy import StegaPy |
| 57 | encrypt = bool(args.password) |
| 58 | plugin, cfg = _make_lsb_plugin( |
| 59 | algo=args.algo, |
| 60 | bits=args.bits, |
| 61 | password=args.password, |
| 62 | compress=not args.no_compress, |
| 63 | encrypt=encrypt, |
| 64 | ) |
| 65 | sp = StegaPy(plugin, cfg) |
| 66 | |
| 67 | cover = _read(args.input) |
| 68 | msg = _read(args.message) |
| 69 | stego = sp.embed_data(msg, os.path.basename(args.message), |
| 70 | cover, os.path.basename(args.input), |
| 71 | os.path.basename(args.output)) |
| 72 | _write(args.output, stego) |
| 73 | print(f"嵌入完成 → {args.output} ({len(msg)/1024:.1f} KB → {len(stego)/1024:.0f} KB)") |
| 74 | |
| 75 | |
| 76 | def cmd_extract(args): |
no test coverage detected