rtty-soda 0.1.6__py3-none-any.whl → 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of rtty-soda might be problematic. Click here for more details.

rtty_soda/main.py CHANGED
@@ -8,14 +8,13 @@ from rtty_soda.archivers import ARCHIVERS, UNARCHIVERS
8
8
  from rtty_soda.cli_io import (
9
9
  print_stats,
10
10
  read_bytes,
11
- read_ciphertext_bytes,
12
- read_clean_bytes,
13
- read_plaintext_bytes,
11
+ read_key_bytes,
12
+ read_password_bytes,
14
13
  write_output,
15
14
  )
16
15
  from rtty_soda.cryptography import public, secret
17
16
  from rtty_soda.cryptography.kdf import KDF_PROFILES, kdf
18
- from rtty_soda.encoders import ENCODERS, RawEncoder
17
+ from rtty_soda.encoders import ENCODERS
19
18
 
20
19
  in_path = click.Path(
21
20
  exists=True,
@@ -39,59 +38,126 @@ def cli() -> None:
39
38
  pass
40
39
 
41
40
 
42
- @cli.command()
41
+ @cli.command() # pyright: ignore[reportAny]
43
42
  @click.option("--encoding", "-e", default="base64", show_default=True)
44
- def genkey_cmd(encoding: str) -> None:
43
+ @click.option("--output-file", "-o", type=out_path, help="Write output to file.")
44
+ @click.option("--group-len", default=0, show_default=True)
45
+ @click.option("--line-len", default=0, show_default=True)
46
+ @click.option("--padding", default=0, show_default=True)
47
+ def genkey_cmd(
48
+ encoding: str, output_file: Path | None, group_len: int, line_len: int, padding: int
49
+ ) -> None:
45
50
  """Generate Private Key.
46
51
 
47
- Encoding: base26 | base36 | base64 | base94
52
+ Encoding: base26 | base31 | base36 | base64 | base94 | binary
48
53
  """
49
54
  enc = ENCODERS[encoding]
50
- key = PrivateKey.generate()
51
- click.echo(key.encode(enc))
55
+ is_bin = encoding == "binary"
56
+
57
+ key = bytes(PrivateKey.generate())
58
+ key = enc.encode(key)
52
59
 
60
+ write_output(
61
+ target=output_file,
62
+ data=key,
63
+ is_binary=is_bin,
64
+ group_len=group_len,
65
+ line_len=line_len,
66
+ padding=padding,
67
+ )
53
68
 
54
- @cli.command()
69
+
70
+ @cli.command() # pyright: ignore[reportAny]
55
71
  @click.argument("private_key_file", type=in_path)
56
72
  @click.option("--encoding", "-e", default="base64", show_default=True)
57
- def pubkey_cmd(private_key_file: Path, encoding: str) -> None:
73
+ @click.option("--output-file", "-o", type=out_path, help="Write output to file.")
74
+ @click.option("--group-len", default=0, show_default=True)
75
+ @click.option("--line-len", default=0, show_default=True)
76
+ @click.option("--padding", default=0, show_default=True)
77
+ def pubkey_cmd(
78
+ private_key_file: Path,
79
+ encoding: str,
80
+ output_file: Path | None,
81
+ group_len: int,
82
+ line_len: int,
83
+ padding: int,
84
+ ) -> None:
58
85
  """Get Public Key.
59
86
 
60
- Encoding: base26 | base36 | base64 | base94
87
+ Encoding: base26 | base31 | base36 | base64 | base94 | binary
61
88
  """
62
89
  enc = ENCODERS[encoding]
63
- key = read_clean_bytes(private_key_file)
64
- priv = PrivateKey(key, enc)
65
- click.echo(priv.public_key.encode(enc))
90
+ is_bin = encoding == "binary"
91
+
92
+ priv = read_key_bytes(source=private_key_file, is_binary=is_bin, encoder=enc)
93
+ priv = PrivateKey(private_key=priv)
94
+ pub = bytes(priv.public_key)
95
+ pub = enc.encode(pub)
96
+
97
+ write_output(
98
+ target=output_file,
99
+ data=pub,
100
+ is_binary=is_bin,
101
+ group_len=group_len,
102
+ line_len=line_len,
103
+ padding=padding,
104
+ )
66
105
 
67
106
 
68
- @cli.command()
107
+ @cli.command() # pyright: ignore[reportAny]
69
108
  @click.argument("password_file", type=in_path)
70
109
  @click.option("--encoding", "-e", default="base64", show_default=True)
71
110
  @click.option("--profile", "-p", default="sensitive", show_default=True)
72
- def kdf_cmd(password_file: Path, encoding: str, profile: str) -> None:
111
+ @click.option("--output-file", "-o", type=out_path, help="Write output to file.")
112
+ @click.option("--group-len", default=0, show_default=True)
113
+ @click.option("--line-len", default=0, show_default=True)
114
+ @click.option("--padding", default=0, show_default=True)
115
+ def kdf_cmd(
116
+ password_file: Path,
117
+ encoding: str,
118
+ profile: str,
119
+ output_file: Path | None,
120
+ group_len: int,
121
+ line_len: int,
122
+ padding: int,
123
+ ) -> None:
73
124
  """Key Derivation Function.
74
125
 
75
- Encoding: base26 | base36 | base64 | base94
126
+ Encoding: base26 | base31 | base36 | base64 | base94 | binary
76
127
 
77
128
  Profile: interactive | moderate | sensitive
78
129
  """
79
130
  enc = ENCODERS[encoding]
80
131
  prof = KDF_PROFILES[profile]
81
- pw = read_bytes(password_file)
82
- key = kdf(pw, prof, enc)
83
- click.echo(key)
132
+ is_bin = encoding == "binary"
133
+
134
+ pw = read_password_bytes(password_file)
135
+ key = kdf(password=pw, profile=prof)
136
+ key = enc.encode(key)
84
137
 
138
+ write_output(
139
+ target=output_file,
140
+ data=key,
141
+ is_binary=is_bin,
142
+ group_len=group_len,
143
+ line_len=line_len,
144
+ padding=padding,
145
+ )
85
146
 
86
- @cli.command(aliases=["e"])
147
+
148
+ @cli.command(aliases=["e"]) # pyright: ignore[reportAny]
87
149
  @click.argument("private_key_file", type=in_path)
88
150
  @click.argument("public_key_file", type=in_path)
89
151
  @click.argument("message_file", type=in_path)
90
152
  @click.option("--key-encoding", default="base64", show_default=True)
91
153
  @click.option("--data-encoding", "-e", default="base64", show_default=True)
92
- @click.option("--compression", "-c", default="zlib", show_default=True)
93
- @click.option("--output-file", "-o", type=out_path, help="(Optional)")
94
- def encrypt_public_cmd( # noqa: PLR0913
154
+ @click.option("--compression", "-c", default="zstd", show_default=True)
155
+ @click.option("--output-file", "-o", type=out_path, help="Write output to file.")
156
+ @click.option("--group-len", default=0, show_default=True)
157
+ @click.option("--line-len", default=0, show_default=True)
158
+ @click.option("--padding", default=0, show_default=True)
159
+ @click.option("--verbose", "-v", is_flag=True, help="Show verbose output.")
160
+ def encrypt_public_cmd(
95
161
  private_key_file: Path,
96
162
  public_key_file: Path,
97
163
  message_file: Path,
@@ -99,103 +165,165 @@ def encrypt_public_cmd( # noqa: PLR0913
99
165
  data_encoding: str,
100
166
  compression: str,
101
167
  output_file: Path | None,
168
+ group_len: int,
169
+ line_len: int,
170
+ padding: int,
171
+ verbose: bool,
102
172
  ) -> None:
103
173
  """Encrypt Message (Public).
104
174
 
105
- Encoding: base26 | base36 | base64 | base94 | binary
175
+ Encoding: base26 | base31 | base36 | base64 | base94 | binary
106
176
 
107
- Compression: zlib | bz2 | lzma | raw
177
+ Compression: zstd | zlib | bz2 | lzma | raw
108
178
  """
109
179
  key_enc = ENCODERS[key_encoding]
110
180
  data_enc = ENCODERS[data_encoding]
111
181
  archiver = ARCHIVERS[compression]
112
- priv_bytes = read_clean_bytes(private_key_file)
113
- priv = PrivateKey(priv_bytes, key_enc)
114
- pub_bytes = read_clean_bytes(public_key_file)
115
- pub = PublicKey(pub_bytes, key_enc)
116
- data = stats = read_plaintext_bytes(message_file, data_enc)
182
+ is_bin_key = key_encoding == "binary"
183
+ is_bin_data = data_encoding == "binary"
184
+
185
+ priv = read_key_bytes(
186
+ source=private_key_file, is_binary=is_bin_key, encoder=key_enc
187
+ )
188
+ priv = PrivateKey(private_key=priv)
189
+ pub = read_key_bytes(source=public_key_file, is_binary=is_bin_key, encoder=key_enc)
190
+ pub = PublicKey(public_key=pub)
191
+ data = stats = message_file.read_bytes()
117
192
  data = archiver(data)
118
- data = public.encrypt(private=priv, public=pub, data=data, out_enc=data_enc)
119
- write_output(output_file, data, data_enc)
120
- print_stats(stats, data)
121
-
122
-
123
- @cli.command(aliases=["es"])
193
+ data = public.encrypt(private=priv, public=pub, data=data)
194
+ data = data_enc.encode(data)
195
+
196
+ write_output(
197
+ target=output_file,
198
+ data=data,
199
+ is_binary=is_bin_data,
200
+ group_len=group_len,
201
+ line_len=line_len,
202
+ padding=padding,
203
+ )
204
+ if verbose:
205
+ print_stats(plaintext=stats, ciphertext=data)
206
+
207
+
208
+ @cli.command(aliases=["es"]) # pyright: ignore[reportAny]
124
209
  @click.argument("key_file", type=in_path)
125
210
  @click.argument("message_file", type=in_path)
126
211
  @click.option("--key-encoding", default="base64", show_default=True)
127
212
  @click.option("--data-encoding", "-e", default="base64", show_default=True)
128
- @click.option("--compression", "-c", default="zlib", show_default=True)
129
- @click.option("--output-file", "-o", type=out_path, help="(Optional)")
130
- def encrypt_secret_cmd( # noqa: PLR0913
213
+ @click.option("--compression", "-c", default="zstd", show_default=True)
214
+ @click.option("--output-file", "-o", type=out_path, help="Write output to file.")
215
+ @click.option("--group-len", default=0, show_default=True)
216
+ @click.option("--line-len", default=0, show_default=True)
217
+ @click.option("--padding", default=0, show_default=True)
218
+ @click.option("--verbose", "-v", is_flag=True, help="Show verbose output.")
219
+ def encrypt_secret_cmd(
131
220
  key_file: Path,
132
221
  message_file: Path,
133
222
  key_encoding: str,
134
223
  data_encoding: str,
135
224
  compression: str,
136
225
  output_file: Path | None,
226
+ group_len: int,
227
+ line_len: int,
228
+ padding: int,
229
+ verbose: bool,
137
230
  ) -> None:
138
231
  """Encrypt Message (Secret).
139
232
 
140
- Encoding: base26 | base36 | base64 | base94 | binary
233
+ Encoding: base26 | base31 | base36 | base64 | base94 | binary
141
234
 
142
- Compression: zlib | bz2 | lzma | raw
235
+ Compression: zstd | zlib | bz2 | lzma | raw
143
236
  """
144
237
  key_enc = ENCODERS[key_encoding]
145
238
  data_enc = ENCODERS[data_encoding]
146
239
  archiver = ARCHIVERS[compression]
147
- key = read_clean_bytes(key_file)
148
- data = stats = read_plaintext_bytes(message_file, data_enc)
149
- data = archiver(data)
150
- data = secret.encrypt(key=key, data=data, key_enc=key_enc, out_enc=data_enc)
151
- write_output(output_file, data, data_enc)
152
- print_stats(stats, data)
153
-
240
+ is_bin_key = key_encoding == "binary"
241
+ is_bin_data = data_encoding == "binary"
154
242
 
155
- @cli.command(aliases=["ep"])
243
+ key = read_key_bytes(source=key_file, is_binary=is_bin_key, encoder=key_enc)
244
+ data = stats = message_file.read_bytes()
245
+ data = archiver(data)
246
+ data = secret.encrypt(key=key, data=data)
247
+ data = data_enc.encode(data)
248
+
249
+ write_output(
250
+ target=output_file,
251
+ data=data,
252
+ is_binary=is_bin_data,
253
+ group_len=group_len,
254
+ line_len=line_len,
255
+ padding=padding,
256
+ )
257
+ if verbose:
258
+ print_stats(plaintext=stats, ciphertext=data)
259
+
260
+
261
+ @cli.command(aliases=["ep"]) # pyright: ignore[reportAny]
156
262
  @click.argument("password_file", type=in_path)
157
263
  @click.argument("message_file", type=in_path)
158
264
  @click.option("--kdf-profile", "-p", default="sensitive", show_default=True)
159
265
  @click.option("--data-encoding", "-e", default="base64", show_default=True)
160
- @click.option("--compression", "-c", default="zlib", show_default=True)
161
- @click.option("--output-file", "-o", type=out_path, help="(Optional)")
162
- def encrypt_password_cmd( # noqa: PLR0913
266
+ @click.option("--compression", "-c", default="zstd", show_default=True)
267
+ @click.option("--output-file", "-o", type=out_path, help="Write output to file.")
268
+ @click.option("--group-len", default=0, show_default=True)
269
+ @click.option("--line-len", default=0, show_default=True)
270
+ @click.option("--padding", default=0, show_default=True)
271
+ @click.option("--verbose", "-v", is_flag=True, help="Show verbose output.")
272
+ def encrypt_password_cmd(
163
273
  password_file: Path,
164
274
  message_file: Path,
165
275
  kdf_profile: str,
166
276
  data_encoding: str,
167
277
  compression: str,
168
278
  output_file: Path | None,
279
+ group_len: int,
280
+ line_len: int,
281
+ padding: int,
282
+ verbose: bool,
169
283
  ) -> None:
170
284
  """Encrypt Message (Password).
171
285
 
172
286
  KDF profile: interactive | moderate | sensitive
173
287
 
174
- Encoding: base26 | base36 | base64 | base94 | binary
288
+ Encoding: base26 | base31 | base36 | base64 | base94 | binary
175
289
 
176
- Compression: zlib | bz2 | lzma | raw
290
+ Compression: zstd | zlib | bz2 | lzma | raw
177
291
  """
178
292
  prof = KDF_PROFILES[kdf_profile]
179
293
  data_enc = ENCODERS[data_encoding]
180
294
  archiver = ARCHIVERS[compression]
181
- pw = read_bytes(password_file)
182
- key = kdf(pw, prof, RawEncoder)
183
- data = stats = read_plaintext_bytes(message_file, data_enc)
184
- data = archiver(data)
185
- data = secret.encrypt(key=key, data=data, key_enc=RawEncoder, out_enc=data_enc)
186
- write_output(output_file, data, data_enc)
187
- print_stats(stats, data)
295
+ is_bin_data = data_encoding == "binary"
188
296
 
189
-
190
- @cli.command(aliases=["d"])
297
+ pw = read_password_bytes(password_file)
298
+ key = kdf(password=pw, profile=prof)
299
+ data = stats = message_file.read_bytes()
300
+ data = archiver(data)
301
+ data = secret.encrypt(key=key, data=data)
302
+ data = data_enc.encode(data)
303
+
304
+ write_output(
305
+ target=output_file,
306
+ data=data,
307
+ is_binary=is_bin_data,
308
+ group_len=group_len,
309
+ line_len=line_len,
310
+ padding=padding,
311
+ )
312
+ if verbose:
313
+ print_stats(plaintext=stats, ciphertext=data)
314
+
315
+
316
+ @cli.command(aliases=["d"]) # pyright: ignore[reportAny]
191
317
  @click.argument("private_key_file", type=in_path)
192
318
  @click.argument("public_key_file", type=in_path)
193
319
  @click.argument("message_file", type=in_path)
194
320
  @click.option("--key-encoding", default="base64", show_default=True)
195
321
  @click.option("--data-encoding", "-e", default="base64", show_default=True)
196
- @click.option("--compression", "-c", default="zlib", show_default=True)
197
- @click.option("--output-file", "-o", type=out_path, help="(Optional)")
198
- def decrypt_public_cmd( # noqa: PLR0913
322
+ @click.option("--compression", "-c", default="zstd", show_default=True)
323
+ @click.option("--output-file", "-o", type=out_path, help="Write output to file.")
324
+ @click.option("--padding", default=0, show_default=True)
325
+ @click.option("--verbose", "-v", is_flag=True, help="Show verbose output.")
326
+ def decrypt_public_cmd(
199
327
  private_key_file: Path,
200
328
  public_key_file: Path,
201
329
  message_file: Path,
@@ -203,112 +331,182 @@ def decrypt_public_cmd( # noqa: PLR0913
203
331
  data_encoding: str,
204
332
  compression: str,
205
333
  output_file: Path | None,
334
+ padding: int,
335
+ verbose: bool,
206
336
  ) -> None:
207
337
  """Decrypt Message (Public).
208
338
 
209
- Encoding: base26 | base36 | base64 | base94 | binary
339
+ Encoding: base26 | base31 | base36 | base64 | base94 | binary
210
340
 
211
- Compression: zlib | bz2 | lzma | raw
341
+ Compression: zstd | zlib | bz2 | lzma | raw
212
342
  """
213
343
  key_enc = ENCODERS[key_encoding]
214
344
  data_enc = ENCODERS[data_encoding]
215
345
  unarchiver = UNARCHIVERS[compression]
216
- priv_bytes = read_clean_bytes(private_key_file)
217
- priv = PrivateKey(priv_bytes, key_enc)
218
- pub_bytes = read_clean_bytes(public_key_file)
219
- pub = PublicKey(pub_bytes, key_enc)
220
- data = stats = read_ciphertext_bytes(message_file, data_enc)
221
- data = public.decrypt(priv, pub, data, data_enc)
346
+ is_bin_key = key_encoding == "binary"
347
+ is_bin_data = data_encoding == "binary"
348
+
349
+ priv = read_key_bytes(
350
+ source=private_key_file, is_binary=is_bin_key, encoder=key_enc
351
+ )
352
+ priv = PrivateKey(private_key=priv)
353
+ pub = read_key_bytes(source=public_key_file, is_binary=is_bin_key, encoder=key_enc)
354
+ pub = PublicKey(public_key=pub)
355
+ data = stats = read_bytes(source=message_file, is_binary=is_bin_data)
356
+ data = data_enc.decode(data)
357
+ data = public.decrypt(private=priv, public=pub, data=data)
222
358
  data = unarchiver(data)
223
- write_output(output_file, data, data_enc)
224
- print_stats(data, stats)
359
+
360
+ write_output(
361
+ target=output_file,
362
+ data=data,
363
+ is_binary=True,
364
+ group_len=0,
365
+ line_len=0,
366
+ padding=padding,
367
+ )
368
+ if verbose:
369
+ print_stats(plaintext=data, ciphertext=stats)
225
370
 
226
371
 
227
- @cli.command(aliases=["ds"])
372
+ @cli.command(aliases=["ds"]) # pyright: ignore[reportAny]
228
373
  @click.argument("key_file", type=in_path)
229
374
  @click.argument("message_file", type=in_path)
230
375
  @click.option("--key-encoding", default="base64", show_default=True)
231
376
  @click.option("--data-encoding", "-e", default="base64", show_default=True)
232
- @click.option("--compression", "-c", default="zlib", show_default=True)
233
- @click.option("--output-file", "-o", type=out_path, help="(Optional)")
234
- def decrypt_secret_cmd( # noqa: PLR0913
377
+ @click.option("--compression", "-c", default="zstd", show_default=True)
378
+ @click.option("--output-file", "-o", type=out_path, help="Write output to file.")
379
+ @click.option("--padding", default=0, show_default=True)
380
+ @click.option("--verbose", "-v", is_flag=True, help="Show verbose output.")
381
+ def decrypt_secret_cmd(
235
382
  key_file: Path,
236
383
  message_file: Path,
237
384
  key_encoding: str,
238
385
  data_encoding: str,
239
386
  compression: str,
240
387
  output_file: Path | None,
388
+ padding: int,
389
+ verbose: bool,
241
390
  ) -> None:
242
391
  """Decrypt Message (Secret).
243
392
 
244
- Encoding: base26 | base36 | base64 | base94 | binary
393
+ Encoding: base26 | base31 | base36 | base64 | base94 | binary
245
394
 
246
- Compression: zlib | bz2 | lzma | raw
395
+ Compression: zstd | zlib | bz2 | lzma | raw
247
396
  """
248
397
  key_enc = ENCODERS[key_encoding]
249
398
  data_enc = ENCODERS[data_encoding]
250
399
  unarchiver = UNARCHIVERS[compression]
251
- key = read_clean_bytes(key_file)
252
- data = stats = read_ciphertext_bytes(message_file, data_enc)
253
- data = secret.decrypt(key, data, key_enc, data_enc)
400
+ is_bin_key = key_encoding == "binary"
401
+ is_bin_data = data_encoding == "binary"
402
+
403
+ key = read_key_bytes(source=key_file, is_binary=is_bin_key, encoder=key_enc)
404
+ data = stats = read_bytes(source=message_file, is_binary=is_bin_data)
405
+ data = data_enc.decode(data)
406
+ data = secret.decrypt(key=key, data=data)
254
407
  data = unarchiver(data)
255
- write_output(output_file, data, data_enc)
256
- print_stats(data, stats)
408
+
409
+ write_output(
410
+ target=output_file,
411
+ data=data,
412
+ is_binary=True,
413
+ group_len=0,
414
+ line_len=0,
415
+ padding=padding,
416
+ )
417
+ if verbose:
418
+ print_stats(plaintext=data, ciphertext=stats)
257
419
 
258
420
 
259
- @cli.command(aliases=["dp"])
421
+ @cli.command(aliases=["dp"]) # pyright: ignore[reportAny]
260
422
  @click.argument("password_file", type=in_path)
261
423
  @click.argument("message_file", type=in_path)
262
424
  @click.option("--kdf-profile", "-p", default="sensitive", show_default=True)
263
425
  @click.option("--data-encoding", "-e", default="base64", show_default=True)
264
- @click.option("--compression", "-c", default="zlib", show_default=True)
265
- @click.option("--output-file", "-o", type=out_path, help="(Optional)")
266
- def decrypt_password_cmd( # noqa: PLR0913
426
+ @click.option("--compression", "-c", default="zstd", show_default=True)
427
+ @click.option("--output-file", "-o", type=out_path, help="Write output to file.")
428
+ @click.option("--padding", default=0, show_default=True)
429
+ @click.option("--verbose", "-v", is_flag=True, help="Show verbose output.")
430
+ def decrypt_password_cmd(
267
431
  password_file: Path,
268
432
  message_file: Path,
269
433
  kdf_profile: str,
270
434
  data_encoding: str,
271
435
  compression: str,
272
436
  output_file: Path | None,
437
+ padding: int,
438
+ verbose: bool,
273
439
  ) -> None:
274
440
  """Decrypt Message (Password).
275
441
 
276
442
  KDF profile: interactive | moderate | sensitive
277
443
 
278
- Encoding: base26 | base36 | base64 | base94 | binary
444
+ Encoding: base26 | base31 | base36 | base64 | base94 | binary
279
445
 
280
- Compression: zlib | bz2 | lzma | raw
446
+ Compression: zstd | zlib | bz2 | lzma | raw
281
447
  """
282
448
  prof = KDF_PROFILES[kdf_profile]
283
449
  data_enc = ENCODERS[data_encoding]
284
450
  unarchiver = UNARCHIVERS[compression]
285
- pw = read_bytes(password_file)
286
- key = kdf(pw, prof, RawEncoder)
287
- data = stats = read_ciphertext_bytes(message_file, data_enc)
288
- data = secret.decrypt(key, data, RawEncoder, data_enc)
451
+ is_bin_data = data_encoding == "binary"
452
+
453
+ pw = read_password_bytes(password_file)
454
+ key = kdf(password=pw, profile=prof)
455
+ data = stats = read_bytes(source=message_file, is_binary=is_bin_data)
456
+ data = data_enc.decode(data)
457
+ data = secret.decrypt(key=key, data=data)
289
458
  data = unarchiver(data)
290
- write_output(output_file, data, data_enc)
291
- print_stats(data, stats)
459
+
460
+ write_output(
461
+ target=output_file,
462
+ data=data,
463
+ is_binary=True,
464
+ group_len=0,
465
+ line_len=0,
466
+ padding=padding,
467
+ )
468
+ if verbose:
469
+ print_stats(plaintext=data, ciphertext=stats)
292
470
 
293
471
 
294
- @cli.command()
472
+ @cli.command() # pyright: ignore[reportAny]
295
473
  @click.argument("in_encoding")
296
474
  @click.argument("out_encoding")
297
475
  @click.argument("file", type=in_path)
298
- @click.option("--output-file", "-o", type=out_path, help="(Optional)")
476
+ @click.option("--output-file", "-o", type=out_path, help="Write output to file.")
477
+ @click.option("--group-len", default=0, show_default=True)
478
+ @click.option("--line-len", default=0, show_default=True)
479
+ @click.option("--padding", default=0, show_default=True)
299
480
  def encode_cmd(
300
- in_encoding: str, out_encoding: str, file: Path, output_file: Path | None
481
+ in_encoding: str,
482
+ out_encoding: str,
483
+ file: Path,
484
+ output_file: Path | None,
485
+ group_len: int,
486
+ line_len: int,
487
+ padding: int,
301
488
  ) -> None:
302
489
  """Encode File.
303
490
 
304
- Encoding: base26 | base36 | base64 | base94 | binary
491
+ Encoding: base26 | base31 | base36 | base64 | base94 | binary
305
492
  """
306
493
  in_enc = ENCODERS[in_encoding]
307
494
  out_enc = ENCODERS[out_encoding]
308
- data = read_ciphertext_bytes(file, in_enc)
495
+ in_bin = in_encoding == "binary"
496
+ out_bin = out_encoding == "binary"
497
+
498
+ data = read_bytes(source=file, is_binary=in_bin)
309
499
  data = in_enc.decode(data)
310
500
  data = out_enc.encode(data)
311
- write_output(output_file, data, out_enc)
501
+
502
+ write_output(
503
+ target=output_file,
504
+ data=data,
505
+ is_binary=out_bin,
506
+ group_len=group_len,
507
+ line_len=line_len,
508
+ padding=padding,
509
+ )
312
510
 
313
511
 
314
512
  if __name__ == "__main__":