rtty-soda 0.1.3__py3-none-any.whl → 0.1.5__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 CHANGED
@@ -1,4 +1,6 @@
1
+ import random
1
2
  import re
3
+ import string
2
4
  from pathlib import Path
3
5
  from typing import TextIO, cast
4
6
 
@@ -14,6 +16,7 @@ __all__ = [
14
16
  "read_plaintext_bytes",
15
17
  "read_str",
16
18
  "remove_whitespace",
19
+ "write_bytes_atomic",
17
20
  "write_output",
18
21
  ]
19
22
 
@@ -51,6 +54,13 @@ def read_ciphertext_bytes(source: Path, in_enc: Encoder) -> bytes:
51
54
  return read_clean_bytes(source)
52
55
 
53
56
 
57
+ def write_bytes_atomic(target: Path, data: bytes) -> None:
58
+ temp_name = "".join(random.choices(string.ascii_lowercase, k=10)) # noqa: S311
59
+ temp_path = target.parent / temp_name
60
+ temp_path.write_bytes(data)
61
+ temp_path.replace(target)
62
+
63
+
54
64
  def write_output(target: Path | None, data: bytes, out_enc: Encoder) -> None:
55
65
  if target is None or target.stem == "-":
56
66
  if out_enc == RawEncoder:
@@ -67,7 +77,7 @@ def write_output(target: Path | None, data: bytes, out_enc: Encoder) -> None:
67
77
  f"Overwrite the output file? ({target})", default=False, abort=True
68
78
  )
69
79
 
70
- target.write_bytes(data)
80
+ write_bytes_atomic(target, data)
71
81
 
72
82
 
73
83
  def print_stats(plaintext: bytes, ciphertext: bytes) -> None:
@@ -10,6 +10,9 @@ def decode_bytes(data: bytes) -> str:
10
10
 
11
11
 
12
12
  def int_to_base(number: int, alphabet: str) -> str:
13
+ if number == 0:
14
+ return alphabet[0]
15
+
13
16
  result: list[str] = []
14
17
  base = len(alphabet)
15
18
  abs_number = abs(number)
@@ -35,6 +38,9 @@ def bytes_to_base(source: bytes, alphabet: str) -> str:
35
38
 
36
39
 
37
40
  def int_to_bytes(number: int) -> bytes:
41
+ if number == 0:
42
+ return b"\x00"
43
+
38
44
  buffer = bytearray()
39
45
  while number:
40
46
  buffer.append(number & 0xFF)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: rtty-soda
3
- Version: 0.1.3
3
+ Version: 0.1.5
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
@@ -54,8 +54,8 @@ A CLI tool for Unix-like environments to encrypt a RTTY session using NaCl.
54
54
  #### Docker
55
55
 
56
56
  ```
57
- % docker run -it --rm -h rtty-soda -v .:/app/host nett/rtty-soda:0.1.3
58
- % docker run -it --rm -h rtty-soda -v .:/app/host nett/rtty-soda:0.1.3-tools
57
+ % docker run -it --rm -h rtty-soda -v .:/app/host nett/rtty-soda:0.1.5
58
+ % docker run -it --rm -h rtty-soda -v .:/app/host nett/rtty-soda:0.1.5-tools
59
59
  ```
60
60
 
61
61
 
@@ -1,6 +1,6 @@
1
1
  rtty_soda/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  rtty_soda/archivers.py,sha256=pJGt2qAqkoGEXbGTypimJcgKpAhIckde2kx5y4DFSXo,1114
3
- rtty_soda/cli_io.py,sha256=7j-1qh_qrUyUm4-Btnw7uEWvvXyJ7eAPq1gd-U65Z50,1970
3
+ rtty_soda/cli_io.py,sha256=92ckQb_gzgr1wp1cz02K_QPIaF7MXZ4YFftzDreD980,2281
4
4
  rtty_soda/cryptography/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  rtty_soda/cryptography/kdf.py,sha256=9HOKErHZVVTV8VuVrMpoaBSrOqC9V5vxdnjnlXiXs8g,1439
6
6
  rtty_soda/cryptography/public.py,sha256=7ivwfK0JC3ObJ0D0Morjk6VHpavbal9hkNc0Ni16_YE,530
@@ -9,10 +9,10 @@ rtty_soda/encoders/__init__.py,sha256=-5_g7rhBSJ9jjRtuNStdG_bUf19YTeoF1M7d-xJZml
9
9
  rtty_soda/encoders/base26_encoder.py,sha256=75pytJmImUjI0bEy1nVH5x_IBTaxF5FkeLX8YlYaOms,523
10
10
  rtty_soda/encoders/base36_encoder.py,sha256=bfrpFq5TTyAK8LWnWpCVGhoyWniNqpHaAHXQldlvRhY,539
11
11
  rtty_soda/encoders/base94_encoder.py,sha256=DBuTq1qfehGgiQdrshZi_01wYcppkzBli4Jz5cRUylg,527
12
- rtty_soda/encoders/functions.py,sha256=q4T7y7TLMxJwpfoO7Z_5T2JLxAkRh6OU927o136ck8o,1257
12
+ rtty_soda/encoders/functions.py,sha256=kCjF4rfdHhBmgY2IjvtmIk0vibXa5fdfqJ5Ao5AXvuc,1349
13
13
  rtty_soda/main.py,sha256=gNrxih6g7FZ-dnNBUWC2f5uaLI4-RUfXHY9GdwcQ-Qs,10416
14
14
  rtty_soda/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
- rtty_soda-0.1.3.dist-info/WHEEL,sha256=-neZj6nU9KAMg2CnCY6T3w8J53nx1kFGw_9HfoSzM60,79
16
- rtty_soda-0.1.3.dist-info/entry_points.txt,sha256=tFROKkaDoE_p5tM2ko7MoAjWBFurchcw3j-MdObxBU0,45
17
- rtty_soda-0.1.3.dist-info/METADATA,sha256=pizs3EHyiP6GcLmGyhUWS6U90Lm4i_NasJJK93bPsKM,6629
18
- rtty_soda-0.1.3.dist-info/RECORD,,
15
+ rtty_soda-0.1.5.dist-info/WHEEL,sha256=-neZj6nU9KAMg2CnCY6T3w8J53nx1kFGw_9HfoSzM60,79
16
+ rtty_soda-0.1.5.dist-info/entry_points.txt,sha256=tFROKkaDoE_p5tM2ko7MoAjWBFurchcw3j-MdObxBU0,45
17
+ rtty_soda-0.1.5.dist-info/METADATA,sha256=p1BdCh37xYG1fVbe8w5ARNagg6t7TeRcy13de3Tvlgo,6629
18
+ rtty_soda-0.1.5.dist-info/RECORD,,