strideutils 0.2.3__tar.gz → 0.2.4__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: strideutils
3
- Version: 0.2.3
3
+ Version: 0.2.4
4
4
  Summary:
5
5
  Author: Your Name
6
6
  Author-email: you@example.com
@@ -17,6 +17,7 @@ Requires-Dist: google-auth-oauthlib (>=1.1.0)
17
17
  Requires-Dist: google-cloud-bigquery (>=3.11.4)
18
18
  Requires-Dist: gspread (>=6.0.2)
19
19
  Requires-Dist: pandas (>=2.1.1)
20
+ Requires-Dist: pycryptodome (>=3.20.0)
20
21
  Requires-Dist: python-dateutil (>=2.8.2)
21
22
  Requires-Dist: pytz (>=2023.3)
22
23
  Requires-Dist: pyyaml (>=6.0.1)
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "strideutils"
3
- version = "0.2.3"
3
+ version = "0.2.4"
4
4
  description = ""
5
5
  authors = ["Your Name <you@example.com>"]
6
6
  readme = "README.md"
@@ -21,9 +21,13 @@ pandas = ">=2.1.1"
21
21
  twilio = ">=8.10.0"
22
22
  tabulate = ">=0.9.0"
23
23
  pyyaml = ">=6.0.1"
24
- python-dateutil= ">=2.8.2"
24
+ python-dateutil = ">=2.8.2"
25
+ pycryptodome = ">=3.20.0"
25
26
 
26
27
 
28
+ [tool.poetry.group.dev.dependencies]
29
+ pytest = "^8.1.1"
30
+
27
31
  [build-system]
28
32
  requires = ["poetry-core"]
29
33
  build-backend = "poetry.core.masonry.api"
@@ -0,0 +1,37 @@
1
+ import base64
2
+ from typing import Tuple
3
+
4
+ from Crypto.Cipher import AES
5
+ from Crypto.Random import get_random_bytes
6
+ from Crypto.Util.Padding import pad, unpad
7
+
8
+
9
+ def encrypt_message(message: str, key: bytes) -> Tuple[str, str]:
10
+ """Encrypt the message using AES in CBC mode."""
11
+ # Generate a random initialization vector
12
+ iv = get_random_bytes(AES.block_size)
13
+
14
+ # Initialize the cipher for encryption
15
+ cipher_encrypt = AES.new(key, AES.MODE_CBC, iv)
16
+
17
+ # Encrypt the message
18
+ # The message needs to be padded to make sure its length is a multiple of the block size
19
+ encrypted = cipher_encrypt.encrypt(pad(message.encode(), AES.block_size))
20
+
21
+ # Return the encrypted data and the IV
22
+ return base64.b64encode(encrypted).decode(), base64.b64encode(iv).decode()
23
+
24
+
25
+ def decrypt_message(encrypted: str, iv: str, key: bytes) -> str:
26
+ """Decrypt the message using AES in CBC mode."""
27
+ # Decode the encrypted message and IV from base64
28
+ encrypted = base64.b64decode(encrypted)
29
+ iv = base64.b64decode(iv)
30
+
31
+ # Initialize the cipher for decryption
32
+ cipher_decrypt = AES.new(key, AES.MODE_CBC, iv)
33
+
34
+ # Decrypt the message and unpad it
35
+ decrypted = unpad(cipher_decrypt.decrypt(encrypted), AES.block_size).decode()
36
+
37
+ return decrypted
File without changes