MCPcopy Create free account
hub / github.com/echQoQ/RustSL / main

Function main

encrypt.py:71–121  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

69
70
71def main():
72 plugins = load_plugins()
73 plugin_names = [getattr(p, 'name', None) for p in plugins]
74 plugin_names = [n for n in plugin_names if n]
75
76 parser = build_base_parser(plugin_names)
77 # parse initial to know selected plugin
78 args, _ = parser.parse_known_args()
79 if args.method is None:
80 parser.print_help()
81 raise SystemExit(1)
82 # find plugin object
83 selected = None
84 for p in plugins:
85 if getattr(p, 'name', None) == args.method:
86 selected = p
87 break
88 if selected is None:
89 raise SystemExit(f"Unsupported --method: {args.method}")
90 # let plugin add arguments if needed
91 if hasattr(selected, 'add_arguments') and callable(selected.add_arguments):
92 selected.add_arguments(parser)
93 # final parse
94 args = parser.parse_args()
95
96 data = read_binary_file(args.input)
97 if data is None:
98 return
99
100 # call plugin to produce final bytes (pre-encode)
101 if hasattr(selected, 'process') and callable(selected.process):
102 final = selected.process(data, args)
103 elif hasattr(selected, 'process_data') and callable(selected.process_data):
104 final = selected.process_data(data, args)
105 else:
106 raise SystemExit(f"Plugin for {args.method} does not expose a process function")
107
108 # Apply encoding based on --encode option
109 if args.encode == "base64":
110 final = base64.b64encode(final)
111 elif args.encode == "base32":
112 final = base64.b32encode(final)
113 elif args.encode == "hex":
114 final = binascii.hexlify(final)
115 elif args.encode == "urlsafe_base64":
116 final = base64.urlsafe_b64encode(final)
117 elif args.encode == "none":
118 pass # final remains as bytes
119
120 save(args.output, final)
121 print(f"Encrypted data (method={args.method}, encode={args.encode}) saved to {args.output}")
122
123
124if __name__ == '__main__':

Callers 1

encrypt.pyFile · 0.70

Calls 4

load_pluginsFunction · 0.85
build_base_parserFunction · 0.85
read_binary_fileFunction · 0.85
saveFunction · 0.85

Tested by

no test coverage detected