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