rtty-soda 0.2.0__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/cli_io.py +16 -19
- rtty_soda/encoders/base26_encoder.py +4 -2
- rtty_soda/encoders/base31_encoder.py +5 -2
- rtty_soda/encoders/base36_encoder.py +4 -2
- rtty_soda/encoders/base64_encoder.py +4 -3
- rtty_soda/encoders/base94_encoder.py +5 -2
- rtty_soda/encoders/encoder.py +2 -0
- rtty_soda/encoders/raw_encoder.py +4 -2
- rtty_soda/main.py +43 -116
- {rtty_soda-0.2.0.dist-info → rtty_soda-0.2.1.dist-info}/METADATA +3 -4
- rtty_soda-0.2.1.dist-info/RECORD +23 -0
- {rtty_soda-0.2.0.dist-info → rtty_soda-0.2.1.dist-info}/WHEEL +1 -1
- rtty_soda-0.2.0.dist-info/RECORD +0 -23
- {rtty_soda-0.2.0.dist-info → rtty_soda-0.2.1.dist-info}/entry_points.txt +0 -0
rtty_soda/cli_io.py
CHANGED
|
@@ -11,6 +11,7 @@ import click
|
|
|
11
11
|
from rtty_soda.encoders import Encoder, decode_bytes, encode_str
|
|
12
12
|
|
|
13
13
|
__all__ = [
|
|
14
|
+
"format_output",
|
|
14
15
|
"pad_newlines",
|
|
15
16
|
"print_stats",
|
|
16
17
|
"read_bytes",
|
|
@@ -40,15 +41,15 @@ def read_encoded_stripped(source: Path) -> bytes:
|
|
|
40
41
|
return encode_str(data)
|
|
41
42
|
|
|
42
43
|
|
|
43
|
-
def read_bytes(source: Path,
|
|
44
|
-
if is_binary:
|
|
44
|
+
def read_bytes(source: Path, encoder: Encoder) -> bytes:
|
|
45
|
+
if encoder.is_binary:
|
|
45
46
|
return source.read_bytes()
|
|
46
47
|
|
|
47
48
|
return read_encoded_stripped(source)
|
|
48
49
|
|
|
49
50
|
|
|
50
|
-
def read_key_bytes(source: Path,
|
|
51
|
-
key = read_bytes(source,
|
|
51
|
+
def read_key_bytes(source: Path, encoder: Encoder) -> bytes:
|
|
52
|
+
key = read_bytes(source, encoder)
|
|
52
53
|
return encoder.decode(key)
|
|
53
54
|
|
|
54
55
|
|
|
@@ -84,27 +85,23 @@ def split_groups(data: str, group_len: int, line_len: int) -> str:
|
|
|
84
85
|
return "\n".join(result)
|
|
85
86
|
|
|
86
87
|
|
|
87
|
-
def pad_newlines(data:
|
|
88
|
-
padding =
|
|
89
|
-
return padding + data + padding
|
|
88
|
+
def pad_newlines(data: str, count: int) -> str:
|
|
89
|
+
padding = "\n" * count
|
|
90
|
+
return padding + data.strip() + "\n" + padding
|
|
90
91
|
|
|
91
92
|
|
|
92
|
-
def
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
is_binary: bool,
|
|
96
|
-
group_len: int,
|
|
97
|
-
line_len: int,
|
|
98
|
-
padding: int,
|
|
99
|
-
) -> None:
|
|
100
|
-
if not is_binary and (group_len > 0 or line_len > 0):
|
|
101
|
-
text = decode_bytes(data)
|
|
93
|
+
def format_output(data: bytes, group_len: int, line_len: int, padding: int) -> bytes:
|
|
94
|
+
text = decode_bytes(data)
|
|
95
|
+
if group_len > 0 or line_len > 0:
|
|
102
96
|
text = split_groups(text, group_len, line_len)
|
|
103
|
-
data = encode_str(text)
|
|
104
97
|
|
|
105
98
|
if padding > 0:
|
|
106
|
-
|
|
99
|
+
text = pad_newlines(text, padding)
|
|
107
100
|
|
|
101
|
+
return encode_str(text)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def write_output(target: Path | None, data: bytes) -> None:
|
|
108
105
|
if target is None or target.stem == "-":
|
|
109
106
|
add_nl = not data.endswith(b"\n")
|
|
110
107
|
click.echo(data, nl=add_nl)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import string
|
|
2
|
+
from typing import ClassVar
|
|
2
3
|
|
|
3
|
-
from .encoder import Encoder
|
|
4
4
|
from .functions import base_to_bytes, bytes_to_base, decode_bytes, encode_str
|
|
5
5
|
|
|
6
6
|
__all__ = ["ALPHABET", "Base26Encoder"]
|
|
@@ -8,7 +8,9 @@ __all__ = ["ALPHABET", "Base26Encoder"]
|
|
|
8
8
|
ALPHABET = string.ascii_uppercase
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
class Base26Encoder
|
|
11
|
+
class Base26Encoder:
|
|
12
|
+
is_binary: ClassVar = False
|
|
13
|
+
|
|
12
14
|
@staticmethod
|
|
13
15
|
def encode(data: bytes) -> bytes:
|
|
14
16
|
return encode_str(bytes_to_base(data, ALPHABET))
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
from
|
|
1
|
+
from typing import ClassVar
|
|
2
|
+
|
|
2
3
|
from .functions import base_to_bytes, bytes_to_base, decode_bytes, encode_str
|
|
3
4
|
|
|
4
5
|
__all__ = ["ALPHABET", "Base31Encoder"]
|
|
@@ -6,7 +7,9 @@ __all__ = ["ALPHABET", "Base31Encoder"]
|
|
|
6
7
|
ALPHABET = "АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЬЫЭЮЯ"
|
|
7
8
|
|
|
8
9
|
|
|
9
|
-
class Base31Encoder
|
|
10
|
+
class Base31Encoder:
|
|
11
|
+
is_binary: ClassVar = False
|
|
12
|
+
|
|
10
13
|
@staticmethod
|
|
11
14
|
def encode(data: bytes) -> bytes:
|
|
12
15
|
return encode_str(bytes_to_base(data, ALPHABET))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import string
|
|
2
|
+
from typing import ClassVar
|
|
2
3
|
|
|
3
|
-
from .encoder import Encoder
|
|
4
4
|
from .functions import base_to_bytes, bytes_to_base, decode_bytes, encode_str
|
|
5
5
|
|
|
6
6
|
__all__ = ["ALPHABET", "Base36Encoder"]
|
|
@@ -8,7 +8,9 @@ __all__ = ["ALPHABET", "Base36Encoder"]
|
|
|
8
8
|
ALPHABET = string.digits + string.ascii_uppercase
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
class Base36Encoder
|
|
11
|
+
class Base36Encoder:
|
|
12
|
+
is_binary: ClassVar = False
|
|
13
|
+
|
|
12
14
|
@staticmethod
|
|
13
15
|
def encode(data: bytes) -> bytes:
|
|
14
16
|
return encode_str(bytes_to_base(data, ALPHABET))
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import base64
|
|
2
|
-
|
|
3
|
-
from .encoder import Encoder
|
|
2
|
+
from typing import ClassVar
|
|
4
3
|
|
|
5
4
|
__all__ = ["Base64Encoder"]
|
|
6
5
|
|
|
7
6
|
|
|
8
|
-
class Base64Encoder
|
|
7
|
+
class Base64Encoder:
|
|
8
|
+
is_binary: ClassVar = False
|
|
9
|
+
|
|
9
10
|
@staticmethod
|
|
10
11
|
def encode(data: bytes) -> bytes:
|
|
11
12
|
return base64.b64encode(data)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
from
|
|
1
|
+
from typing import ClassVar
|
|
2
|
+
|
|
2
3
|
from .functions import base_to_bytes, bytes_to_base, decode_bytes, encode_str
|
|
3
4
|
|
|
4
5
|
__all__ = ["ALPHABET", "Base94Encoder"]
|
|
@@ -6,7 +7,9 @@ __all__ = ["ALPHABET", "Base94Encoder"]
|
|
|
6
7
|
ALPHABET = "".join([chr(i) for i in range(33, 127)])
|
|
7
8
|
|
|
8
9
|
|
|
9
|
-
class Base94Encoder
|
|
10
|
+
class Base94Encoder:
|
|
11
|
+
is_binary: ClassVar = False
|
|
12
|
+
|
|
10
13
|
@staticmethod
|
|
11
14
|
def encode(data: bytes) -> bytes:
|
|
12
15
|
return encode_str(bytes_to_base(data, ALPHABET))
|
rtty_soda/encoders/encoder.py
CHANGED
rtty_soda/main.py
CHANGED
|
@@ -6,6 +6,7 @@ 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
|
read_key_bytes,
|
|
@@ -52,19 +53,14 @@ def genkey_cmd(
|
|
|
52
53
|
Encoding: base26 | base31 | base36 | base64 | base94 | binary
|
|
53
54
|
"""
|
|
54
55
|
enc = ENCODERS[encoding]
|
|
55
|
-
is_bin = encoding == "binary"
|
|
56
56
|
|
|
57
57
|
key = bytes(PrivateKey.generate())
|
|
58
58
|
key = enc.encode(key)
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
group_len=group_len,
|
|
65
|
-
line_len=line_len,
|
|
66
|
-
padding=padding,
|
|
67
|
-
)
|
|
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)
|
|
68
64
|
|
|
69
65
|
|
|
70
66
|
@cli.command() # pyright: ignore[reportAny]
|
|
@@ -87,21 +83,16 @@ def pubkey_cmd(
|
|
|
87
83
|
Encoding: base26 | base31 | base36 | base64 | base94 | binary
|
|
88
84
|
"""
|
|
89
85
|
enc = ENCODERS[encoding]
|
|
90
|
-
is_bin = encoding == "binary"
|
|
91
86
|
|
|
92
|
-
priv = read_key_bytes(source=private_key_file,
|
|
87
|
+
priv = read_key_bytes(source=private_key_file, encoder=enc)
|
|
93
88
|
priv = PrivateKey(private_key=priv)
|
|
94
89
|
pub = bytes(priv.public_key)
|
|
95
90
|
pub = enc.encode(pub)
|
|
96
91
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
group_len=group_len,
|
|
102
|
-
line_len=line_len,
|
|
103
|
-
padding=padding,
|
|
104
|
-
)
|
|
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)
|
|
105
96
|
|
|
106
97
|
|
|
107
98
|
@cli.command() # pyright: ignore[reportAny]
|
|
@@ -129,20 +120,15 @@ def kdf_cmd(
|
|
|
129
120
|
"""
|
|
130
121
|
enc = ENCODERS[encoding]
|
|
131
122
|
prof = KDF_PROFILES[profile]
|
|
132
|
-
is_bin = encoding == "binary"
|
|
133
123
|
|
|
134
124
|
pw = read_password_bytes(password_file)
|
|
135
125
|
key = kdf(password=pw, profile=prof)
|
|
136
126
|
key = enc.encode(key)
|
|
137
127
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
group_len=group_len,
|
|
143
|
-
line_len=line_len,
|
|
144
|
-
padding=padding,
|
|
145
|
-
)
|
|
128
|
+
if not enc.is_binary:
|
|
129
|
+
key = format_output(key, group_len, line_len, padding)
|
|
130
|
+
|
|
131
|
+
write_output(target=output_file, data=key)
|
|
146
132
|
|
|
147
133
|
|
|
148
134
|
@cli.command(aliases=["e"]) # pyright: ignore[reportAny]
|
|
@@ -179,28 +165,20 @@ def encrypt_public_cmd(
|
|
|
179
165
|
key_enc = ENCODERS[key_encoding]
|
|
180
166
|
data_enc = ENCODERS[data_encoding]
|
|
181
167
|
archiver = ARCHIVERS[compression]
|
|
182
|
-
is_bin_key = key_encoding == "binary"
|
|
183
|
-
is_bin_data = data_encoding == "binary"
|
|
184
168
|
|
|
185
|
-
priv = read_key_bytes(
|
|
186
|
-
source=private_key_file, is_binary=is_bin_key, encoder=key_enc
|
|
187
|
-
)
|
|
169
|
+
priv = read_key_bytes(source=private_key_file, encoder=key_enc)
|
|
188
170
|
priv = PrivateKey(private_key=priv)
|
|
189
|
-
pub = read_key_bytes(source=public_key_file,
|
|
171
|
+
pub = read_key_bytes(source=public_key_file, encoder=key_enc)
|
|
190
172
|
pub = PublicKey(public_key=pub)
|
|
191
173
|
data = stats = message_file.read_bytes()
|
|
192
174
|
data = archiver(data)
|
|
193
175
|
data = public.encrypt(private=priv, public=pub, data=data)
|
|
194
176
|
data = data_enc.encode(data)
|
|
195
177
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
group_len=group_len,
|
|
201
|
-
line_len=line_len,
|
|
202
|
-
padding=padding,
|
|
203
|
-
)
|
|
178
|
+
if not data_enc.is_binary:
|
|
179
|
+
data = format_output(data, group_len, line_len, padding)
|
|
180
|
+
|
|
181
|
+
write_output(target=output_file, data=data)
|
|
204
182
|
if verbose:
|
|
205
183
|
print_stats(plaintext=stats, ciphertext=data)
|
|
206
184
|
|
|
@@ -237,23 +215,17 @@ def encrypt_secret_cmd(
|
|
|
237
215
|
key_enc = ENCODERS[key_encoding]
|
|
238
216
|
data_enc = ENCODERS[data_encoding]
|
|
239
217
|
archiver = ARCHIVERS[compression]
|
|
240
|
-
is_bin_key = key_encoding == "binary"
|
|
241
|
-
is_bin_data = data_encoding == "binary"
|
|
242
218
|
|
|
243
|
-
key = read_key_bytes(source=key_file,
|
|
219
|
+
key = read_key_bytes(source=key_file, encoder=key_enc)
|
|
244
220
|
data = stats = message_file.read_bytes()
|
|
245
221
|
data = archiver(data)
|
|
246
222
|
data = secret.encrypt(key=key, data=data)
|
|
247
223
|
data = data_enc.encode(data)
|
|
248
224
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
group_len=group_len,
|
|
254
|
-
line_len=line_len,
|
|
255
|
-
padding=padding,
|
|
256
|
-
)
|
|
225
|
+
if not data_enc.is_binary:
|
|
226
|
+
data = format_output(data, group_len, line_len, padding)
|
|
227
|
+
|
|
228
|
+
write_output(target=output_file, data=data)
|
|
257
229
|
if verbose:
|
|
258
230
|
print_stats(plaintext=stats, ciphertext=data)
|
|
259
231
|
|
|
@@ -292,7 +264,6 @@ def encrypt_password_cmd(
|
|
|
292
264
|
prof = KDF_PROFILES[kdf_profile]
|
|
293
265
|
data_enc = ENCODERS[data_encoding]
|
|
294
266
|
archiver = ARCHIVERS[compression]
|
|
295
|
-
is_bin_data = data_encoding == "binary"
|
|
296
267
|
|
|
297
268
|
pw = read_password_bytes(password_file)
|
|
298
269
|
key = kdf(password=pw, profile=prof)
|
|
@@ -301,14 +272,10 @@ def encrypt_password_cmd(
|
|
|
301
272
|
data = secret.encrypt(key=key, data=data)
|
|
302
273
|
data = data_enc.encode(data)
|
|
303
274
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
group_len=group_len,
|
|
309
|
-
line_len=line_len,
|
|
310
|
-
padding=padding,
|
|
311
|
-
)
|
|
275
|
+
if not data_enc.is_binary:
|
|
276
|
+
data = format_output(data, group_len, line_len, padding)
|
|
277
|
+
|
|
278
|
+
write_output(target=output_file, data=data)
|
|
312
279
|
if verbose:
|
|
313
280
|
print_stats(plaintext=stats, ciphertext=data)
|
|
314
281
|
|
|
@@ -321,7 +288,6 @@ def encrypt_password_cmd(
|
|
|
321
288
|
@click.option("--data-encoding", "-e", default="base64", show_default=True)
|
|
322
289
|
@click.option("--compression", "-c", default="zstd", show_default=True)
|
|
323
290
|
@click.option("--output-file", "-o", type=out_path, help="Write output to file.")
|
|
324
|
-
@click.option("--padding", default=0, show_default=True)
|
|
325
291
|
@click.option("--verbose", "-v", is_flag=True, help="Show verbose output.")
|
|
326
292
|
def decrypt_public_cmd(
|
|
327
293
|
private_key_file: Path,
|
|
@@ -331,7 +297,6 @@ def decrypt_public_cmd(
|
|
|
331
297
|
data_encoding: str,
|
|
332
298
|
compression: str,
|
|
333
299
|
output_file: Path | None,
|
|
334
|
-
padding: int,
|
|
335
300
|
verbose: bool,
|
|
336
301
|
) -> None:
|
|
337
302
|
"""Decrypt Message (Public).
|
|
@@ -343,28 +308,17 @@ def decrypt_public_cmd(
|
|
|
343
308
|
key_enc = ENCODERS[key_encoding]
|
|
344
309
|
data_enc = ENCODERS[data_encoding]
|
|
345
310
|
unarchiver = UNARCHIVERS[compression]
|
|
346
|
-
is_bin_key = key_encoding == "binary"
|
|
347
|
-
is_bin_data = data_encoding == "binary"
|
|
348
311
|
|
|
349
|
-
priv = read_key_bytes(
|
|
350
|
-
source=private_key_file, is_binary=is_bin_key, encoder=key_enc
|
|
351
|
-
)
|
|
312
|
+
priv = read_key_bytes(source=private_key_file, encoder=key_enc)
|
|
352
313
|
priv = PrivateKey(private_key=priv)
|
|
353
|
-
pub = read_key_bytes(source=public_key_file,
|
|
314
|
+
pub = read_key_bytes(source=public_key_file, encoder=key_enc)
|
|
354
315
|
pub = PublicKey(public_key=pub)
|
|
355
|
-
data = stats = read_bytes(source=message_file,
|
|
316
|
+
data = stats = read_bytes(source=message_file, encoder=data_enc)
|
|
356
317
|
data = data_enc.decode(data)
|
|
357
318
|
data = public.decrypt(private=priv, public=pub, data=data)
|
|
358
319
|
data = unarchiver(data)
|
|
359
320
|
|
|
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
|
-
)
|
|
321
|
+
write_output(target=output_file, data=data)
|
|
368
322
|
if verbose:
|
|
369
323
|
print_stats(plaintext=data, ciphertext=stats)
|
|
370
324
|
|
|
@@ -376,7 +330,6 @@ def decrypt_public_cmd(
|
|
|
376
330
|
@click.option("--data-encoding", "-e", default="base64", show_default=True)
|
|
377
331
|
@click.option("--compression", "-c", default="zstd", show_default=True)
|
|
378
332
|
@click.option("--output-file", "-o", type=out_path, help="Write output to file.")
|
|
379
|
-
@click.option("--padding", default=0, show_default=True)
|
|
380
333
|
@click.option("--verbose", "-v", is_flag=True, help="Show verbose output.")
|
|
381
334
|
def decrypt_secret_cmd(
|
|
382
335
|
key_file: Path,
|
|
@@ -385,7 +338,6 @@ def decrypt_secret_cmd(
|
|
|
385
338
|
data_encoding: str,
|
|
386
339
|
compression: str,
|
|
387
340
|
output_file: Path | None,
|
|
388
|
-
padding: int,
|
|
389
341
|
verbose: bool,
|
|
390
342
|
) -> None:
|
|
391
343
|
"""Decrypt Message (Secret).
|
|
@@ -397,23 +349,14 @@ def decrypt_secret_cmd(
|
|
|
397
349
|
key_enc = ENCODERS[key_encoding]
|
|
398
350
|
data_enc = ENCODERS[data_encoding]
|
|
399
351
|
unarchiver = UNARCHIVERS[compression]
|
|
400
|
-
is_bin_key = key_encoding == "binary"
|
|
401
|
-
is_bin_data = data_encoding == "binary"
|
|
402
352
|
|
|
403
|
-
key = read_key_bytes(source=key_file,
|
|
404
|
-
data = stats = read_bytes(source=message_file,
|
|
353
|
+
key = read_key_bytes(source=key_file, encoder=key_enc)
|
|
354
|
+
data = stats = read_bytes(source=message_file, encoder=data_enc)
|
|
405
355
|
data = data_enc.decode(data)
|
|
406
356
|
data = secret.decrypt(key=key, data=data)
|
|
407
357
|
data = unarchiver(data)
|
|
408
358
|
|
|
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
|
-
)
|
|
359
|
+
write_output(target=output_file, data=data)
|
|
417
360
|
if verbose:
|
|
418
361
|
print_stats(plaintext=data, ciphertext=stats)
|
|
419
362
|
|
|
@@ -425,7 +368,6 @@ def decrypt_secret_cmd(
|
|
|
425
368
|
@click.option("--data-encoding", "-e", default="base64", show_default=True)
|
|
426
369
|
@click.option("--compression", "-c", default="zstd", show_default=True)
|
|
427
370
|
@click.option("--output-file", "-o", type=out_path, help="Write output to file.")
|
|
428
|
-
@click.option("--padding", default=0, show_default=True)
|
|
429
371
|
@click.option("--verbose", "-v", is_flag=True, help="Show verbose output.")
|
|
430
372
|
def decrypt_password_cmd(
|
|
431
373
|
password_file: Path,
|
|
@@ -434,7 +376,6 @@ def decrypt_password_cmd(
|
|
|
434
376
|
data_encoding: str,
|
|
435
377
|
compression: str,
|
|
436
378
|
output_file: Path | None,
|
|
437
|
-
padding: int,
|
|
438
379
|
verbose: bool,
|
|
439
380
|
) -> None:
|
|
440
381
|
"""Decrypt Message (Password).
|
|
@@ -448,23 +389,15 @@ def decrypt_password_cmd(
|
|
|
448
389
|
prof = KDF_PROFILES[kdf_profile]
|
|
449
390
|
data_enc = ENCODERS[data_encoding]
|
|
450
391
|
unarchiver = UNARCHIVERS[compression]
|
|
451
|
-
is_bin_data = data_encoding == "binary"
|
|
452
392
|
|
|
453
393
|
pw = read_password_bytes(password_file)
|
|
454
394
|
key = kdf(password=pw, profile=prof)
|
|
455
|
-
data = stats = read_bytes(source=message_file,
|
|
395
|
+
data = stats = read_bytes(source=message_file, encoder=data_enc)
|
|
456
396
|
data = data_enc.decode(data)
|
|
457
397
|
data = secret.decrypt(key=key, data=data)
|
|
458
398
|
data = unarchiver(data)
|
|
459
399
|
|
|
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
|
-
)
|
|
400
|
+
write_output(target=output_file, data=data)
|
|
468
401
|
if verbose:
|
|
469
402
|
print_stats(plaintext=data, ciphertext=stats)
|
|
470
403
|
|
|
@@ -492,21 +425,15 @@ def encode_cmd(
|
|
|
492
425
|
"""
|
|
493
426
|
in_enc = ENCODERS[in_encoding]
|
|
494
427
|
out_enc = ENCODERS[out_encoding]
|
|
495
|
-
in_bin = in_encoding == "binary"
|
|
496
|
-
out_bin = out_encoding == "binary"
|
|
497
428
|
|
|
498
|
-
data = read_bytes(source=file,
|
|
429
|
+
data = read_bytes(source=file, encoder=in_enc)
|
|
499
430
|
data = in_enc.decode(data)
|
|
500
431
|
data = out_enc.encode(data)
|
|
501
432
|
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
group_len=group_len,
|
|
507
|
-
line_len=line_len,
|
|
508
|
-
padding=padding,
|
|
509
|
-
)
|
|
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)
|
|
510
437
|
|
|
511
438
|
|
|
512
439
|
if __name__ == "__main__":
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: rtty-soda
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: A CLI tool for Unix-like environments to encrypt a RTTY session using NaCl
|
|
5
5
|
Keywords: cli,encryption,libsodium,nacl,rtty
|
|
6
6
|
Author: Theo Saveliev
|
|
@@ -57,8 +57,8 @@ A CLI tool for Unix-like environments to encrypt a RTTY session using NaCl.
|
|
|
57
57
|
#### Docker
|
|
58
58
|
|
|
59
59
|
```
|
|
60
|
-
% docker run -it --rm -h rtty-soda -v .:/app/host nett/rtty-soda:0.2.
|
|
61
|
-
% docker run -it --rm -h rtty-soda -v .:/app/host nett/rtty-soda:0.2.
|
|
60
|
+
% docker run -it --rm -h rtty-soda -v .:/app/host nett/rtty-soda:0.2.1
|
|
61
|
+
% docker run -it --rm -h rtty-soda -v .:/app/host nett/rtty-soda:0.2.1-tools
|
|
62
62
|
```
|
|
63
63
|
|
|
64
64
|
|
|
@@ -180,7 +180,6 @@ Options:
|
|
|
180
180
|
-e, --data-encoding TEXT [default: base64]
|
|
181
181
|
-c, --compression TEXT [default: zstd]
|
|
182
182
|
-o, --output-file FILE Write output to file.
|
|
183
|
-
--padding INTEGER [default: 0]
|
|
184
183
|
-v, --verbose Show verbose output.
|
|
185
184
|
-h, --help Show this message and exit.
|
|
186
185
|
```
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
rtty_soda/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
rtty_soda/archivers.py,sha256=b-qZ6-MAY1rm1Jsosi2XEfjNjkU7acAedHmnSzthf-A,1343
|
|
3
|
+
rtty_soda/cli_io.py,sha256=01d0IWv2lpOBB13TKB0ZbiLpSXep9J53lXiOsy9HNEM,3162
|
|
4
|
+
rtty_soda/cryptography/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
rtty_soda/cryptography/kdf.py,sha256=HymfTiK7BD7lhZu0OdtFW_i-v0r7e8XedT8_Q84ClJc,1529
|
|
6
|
+
rtty_soda/cryptography/public.py,sha256=6gwsT4ilaMDHwtdYPOEYlX8IfwHPew8lMIbxRva1mLs,612
|
|
7
|
+
rtty_soda/cryptography/secret.py,sha256=N5ytktC2oxYfTFew0utytEClWK2rMvcnxlqeppR7wDQ,529
|
|
8
|
+
rtty_soda/encoders/__init__.py,sha256=y2_dw7PQRadBKZ6CSPOSqjHyxdiGJ_KmxXSsyQytugk,737
|
|
9
|
+
rtty_soda/encoders/base26_encoder.py,sha256=QXQJI4FBlW5p1rnTgi_D10eOqs86O2JxWHxbOprdenQ,482
|
|
10
|
+
rtty_soda/encoders/base31_encoder.py,sha256=0CIu2gtauL7XbPF1uyphlNI30sqeABsBqitinZmy4Sk,510
|
|
11
|
+
rtty_soda/encoders/base36_encoder.py,sha256=wlEMWGo_S4h7-bH2yYqTeObfdbEk6j3x0ebG4HEufvA,498
|
|
12
|
+
rtty_soda/encoders/base64_encoder.py,sha256=ZEkYHnTj7IeMX1yAHbeL-tLs2K2SaSspypgGB2N71Jw,316
|
|
13
|
+
rtty_soda/encoders/base94_encoder.py,sha256=Xbt0chbeAIM9_nRHVhRMVfMBUKS9q1gNSpg2WhGn2N4,487
|
|
14
|
+
rtty_soda/encoders/encoder.py,sha256=trHunjg0uNEQrQWTpRMY5nQEx5_jBrcvfUAcGIKpgms,220
|
|
15
|
+
rtty_soda/encoders/functions.py,sha256=JxtgbZg3kdbFqAhjm59QwJS6zEXYsR1m02k7cg_rFI4,1385
|
|
16
|
+
rtty_soda/encoders/raw_encoder.py,sha256=eJnUSsxf3jichdQ5LqwvBZAX7-qk67p5FMlfKOOGHp8,259
|
|
17
|
+
rtty_soda/main.py,sha256=QPVvnNkZgMHZQQ7mQUOiHLDuVA1WFfEZVJqgZxp_6hs,14679
|
|
18
|
+
rtty_soda/main.pyi,sha256=1_ahHQ89q7lC2cQ0Vgk4QXwsP0G9c10XYGvrVsO1U0s,2203
|
|
19
|
+
rtty_soda/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
20
|
+
rtty_soda-0.2.1.dist-info/WHEEL,sha256=M6du7VZflc4UPsGphmOXHANdgk8zessdJG0DBUuoA-U,78
|
|
21
|
+
rtty_soda-0.2.1.dist-info/entry_points.txt,sha256=tFROKkaDoE_p5tM2ko7MoAjWBFurchcw3j-MdObxBU0,45
|
|
22
|
+
rtty_soda-0.2.1.dist-info/METADATA,sha256=OXeQ9VdCEzSNtvDtY4dJNVrCR4jPxEVPl88ExekIxbM,9616
|
|
23
|
+
rtty_soda-0.2.1.dist-info/RECORD,,
|
rtty_soda-0.2.0.dist-info/RECORD
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
rtty_soda/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
rtty_soda/archivers.py,sha256=b-qZ6-MAY1rm1Jsosi2XEfjNjkU7acAedHmnSzthf-A,1343
|
|
3
|
-
rtty_soda/cli_io.py,sha256=5c0Jt51zVgLHZMppj9sXl5x8nZsdpeTx7rglHE4w0wg,3170
|
|
4
|
-
rtty_soda/cryptography/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
-
rtty_soda/cryptography/kdf.py,sha256=HymfTiK7BD7lhZu0OdtFW_i-v0r7e8XedT8_Q84ClJc,1529
|
|
6
|
-
rtty_soda/cryptography/public.py,sha256=6gwsT4ilaMDHwtdYPOEYlX8IfwHPew8lMIbxRva1mLs,612
|
|
7
|
-
rtty_soda/cryptography/secret.py,sha256=N5ytktC2oxYfTFew0utytEClWK2rMvcnxlqeppR7wDQ,529
|
|
8
|
-
rtty_soda/encoders/__init__.py,sha256=y2_dw7PQRadBKZ6CSPOSqjHyxdiGJ_KmxXSsyQytugk,737
|
|
9
|
-
rtty_soda/encoders/base26_encoder.py,sha256=E8JD9CKBNsANDi6-7RXobiB-GrWOJX0ThN8A7YtxjzM,459
|
|
10
|
-
rtty_soda/encoders/base31_encoder.py,sha256=23mxVPJSJqrxzlTmGGaV7pvMxnJCArqO-_ZsVAl4UHA,486
|
|
11
|
-
rtty_soda/encoders/base36_encoder.py,sha256=3mPM4nTy_a1BRBqZD5tCjcZGtgUjU3Ew2y4ro9qq-jg,475
|
|
12
|
-
rtty_soda/encoders/base64_encoder.py,sha256=K1y7zVyb4d_YTrP5iONxtJ8hfJpCUcdCAOAoLppcPYk,294
|
|
13
|
-
rtty_soda/encoders/base94_encoder.py,sha256=TP9OYBF9tzIvqbOr5YRRAQt1SCxvnrL1FVOsIbrX8jc,463
|
|
14
|
-
rtty_soda/encoders/encoder.py,sha256=z-NPAqoxl5VlYLED_Zh0OaE7DR2BkStF10_YSaH1fOM,199
|
|
15
|
-
rtty_soda/encoders/functions.py,sha256=JxtgbZg3kdbFqAhjm59QwJS6zEXYsR1m02k7cg_rFI4,1385
|
|
16
|
-
rtty_soda/encoders/raw_encoder.py,sha256=wvOzPG9SvoEaOOOsLfHR8KIdAbSs_6RMAhIyuVmlNFw,237
|
|
17
|
-
rtty_soda/main.py,sha256=g_IHKlQMpv4gquw8NfQVRxV5mv84dp0PsXQAwL49Vjo,16298
|
|
18
|
-
rtty_soda/main.pyi,sha256=1_ahHQ89q7lC2cQ0Vgk4QXwsP0G9c10XYGvrVsO1U0s,2203
|
|
19
|
-
rtty_soda/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
20
|
-
rtty_soda-0.2.0.dist-info/WHEEL,sha256=ELhySV62sOro8I5wRaLaF3TWxhBpkcDkdZUdAYLy_Hk,78
|
|
21
|
-
rtty_soda-0.2.0.dist-info/entry_points.txt,sha256=tFROKkaDoE_p5tM2ko7MoAjWBFurchcw3j-MdObxBU0,45
|
|
22
|
-
rtty_soda-0.2.0.dist-info/METADATA,sha256=Kt9mN0FEH1aPDnVuOwoWT-29hJFa6hH_Y7qt53qEsfE,9657
|
|
23
|
-
rtty_soda-0.2.0.dist-info/RECORD,,
|
|
File without changes
|