spei-python 0.24.0__tar.gz → 0.25.0__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.
- {spei_python-0.24.0 → spei_python-0.25.0}/PKG-INFO +1 -1
- {spei_python-0.24.0 → spei_python-0.25.0}/pyproject.toml +2 -2
- spei_python-0.25.0/spei/cep_generator.py +81 -0
- {spei_python-0.24.0 → spei_python-0.25.0}/README.md +0 -0
- {spei_python-0.24.0 → spei_python-0.25.0}/spei/README.md +0 -0
- {spei_python-0.24.0 → spei_python-0.25.0}/spei/__init__.py +0 -0
- {spei_python-0.24.0 → spei_python-0.25.0}/spei/client.py +0 -0
- {spei_python-0.24.0 → spei_python-0.25.0}/spei/errors.py +0 -0
- {spei_python-0.24.0 → spei_python-0.25.0}/spei/mappings.py +0 -0
- {spei_python-0.24.0 → spei_python-0.25.0}/spei/requests/__init__.py +0 -0
- {spei_python-0.24.0 → spei_python-0.25.0}/spei/requests/cda.py +0 -0
- {spei_python-0.24.0 → spei_python-0.25.0}/spei/requests/orden.py +0 -0
- {spei_python-0.24.0 → spei_python-0.25.0}/spei/requests/respuesta.py +0 -0
- {spei_python-0.24.0 → spei_python-0.25.0}/spei/resources/__init__.py +0 -0
- {spei_python-0.24.0 → spei_python-0.25.0}/spei/resources/acuse.py +0 -0
- {spei_python-0.24.0 → spei_python-0.25.0}/spei/resources/cda.py +0 -0
- {spei_python-0.24.0 → spei_python-0.25.0}/spei/resources/mensaje.py +0 -0
- {spei_python-0.24.0 → spei_python-0.25.0}/spei/resources/orden.py +0 -0
- {spei_python-0.24.0 → spei_python-0.25.0}/spei/resources/respuesta.py +0 -0
- {spei_python-0.24.0 → spei_python-0.25.0}/spei/responses/__init__.py +0 -0
- {spei_python-0.24.0 → spei_python-0.25.0}/spei/responses/acuse.py +0 -0
- {spei_python-0.24.0 → spei_python-0.25.0}/spei/responses/orden.py +0 -0
- {spei_python-0.24.0 → spei_python-0.25.0}/spei/responses/respuesta.py +0 -0
- {spei_python-0.24.0 → spei_python-0.25.0}/spei/sice.py +0 -0
- {spei_python-0.24.0 → spei_python-0.25.0}/spei/types.py +0 -0
- {spei_python-0.24.0 → spei_python-0.25.0}/spei/utils.py +0 -0
- {spei_python-0.24.0 → spei_python-0.25.0}/spei/validators.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "spei-python"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.25.0"
|
|
4
4
|
description = ""
|
|
5
5
|
authors = ["tech <tech@fondeadora.com>"]
|
|
6
6
|
readme = "README.md"
|
|
@@ -32,7 +32,7 @@ build-backend = "poetry.core.masonry.api"
|
|
|
32
32
|
|
|
33
33
|
[tool.commitizen]
|
|
34
34
|
name = "cz_conventional_commits"
|
|
35
|
-
version = "0.
|
|
35
|
+
version = "0.25.0"
|
|
36
36
|
tag_format = "v$version"
|
|
37
37
|
bump_message = "bump: Semantic Release Bot: Release Version: $new_version 🤖🚀 [skip ci]"
|
|
38
38
|
version_files = [
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import base64
|
|
2
|
+
import datetime
|
|
3
|
+
from enum import Enum
|
|
4
|
+
from os import urandom
|
|
5
|
+
|
|
6
|
+
from cryptography.hazmat.backends import default_backend
|
|
7
|
+
from cryptography.hazmat.primitives import padding
|
|
8
|
+
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
|
|
9
|
+
|
|
10
|
+
IV_LIMIT = 16
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class SearchCriteria(Enum):
|
|
14
|
+
TRACKING_CODE = 'T'
|
|
15
|
+
REFERENCE_NUMBER = 'R'
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class CepGenerator(object):
|
|
19
|
+
def __init__(self, key_base64, rng=urandom):
|
|
20
|
+
self.key_base64 = key_base64
|
|
21
|
+
self.rng = rng
|
|
22
|
+
|
|
23
|
+
def generate_cep(
|
|
24
|
+
self,
|
|
25
|
+
date: datetime.datetime,
|
|
26
|
+
search_criteria: SearchCriteria,
|
|
27
|
+
search_value: str,
|
|
28
|
+
origin_bank_code: str,
|
|
29
|
+
receiver_bank_code: str,
|
|
30
|
+
account_number: str,
|
|
31
|
+
amount: float,
|
|
32
|
+
) -> str:
|
|
33
|
+
formatted_date = self._format_date(date)
|
|
34
|
+
string = '{0}|{1}|{2}|{3}|{4}|{5}|{6}'.format(
|
|
35
|
+
formatted_date,
|
|
36
|
+
search_criteria.value,
|
|
37
|
+
search_value,
|
|
38
|
+
origin_bank_code,
|
|
39
|
+
receiver_bank_code,
|
|
40
|
+
account_number,
|
|
41
|
+
amount,
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
return self._encrypt_string(string)
|
|
45
|
+
|
|
46
|
+
def decrypt_string(self, encrypted_data_base64: str) -> str: # noqa: WPS210
|
|
47
|
+
backend = default_backend()
|
|
48
|
+
encrypted_data = base64.b64decode(encrypted_data_base64)
|
|
49
|
+
iv = encrypted_data[:IV_LIMIT]
|
|
50
|
+
cipher = Cipher(
|
|
51
|
+
algorithms.AES(base64.b64decode(self.key_base64)),
|
|
52
|
+
modes.CBC(iv),
|
|
53
|
+
backend=backend,
|
|
54
|
+
)
|
|
55
|
+
decryptor = cipher.decryptor()
|
|
56
|
+
decrypted_data = decryptor.update(
|
|
57
|
+
encrypted_data[IV_LIMIT:],
|
|
58
|
+
) + decryptor.finalize()
|
|
59
|
+
unpadder = padding.PKCS7(algorithms.AES.block_size).unpadder()
|
|
60
|
+
unpadded_data = unpadder.update(decrypted_data) + unpadder.finalize()
|
|
61
|
+
|
|
62
|
+
return unpadded_data.decode()
|
|
63
|
+
|
|
64
|
+
def _format_date(self, date: datetime.datetime) -> str:
|
|
65
|
+
return date.strftime('%Y%m%d')
|
|
66
|
+
|
|
67
|
+
def _encrypt_string(self, string: str) -> str: # noqa: WPS210
|
|
68
|
+
backend = default_backend()
|
|
69
|
+
iv = self.rng(IV_LIMIT)
|
|
70
|
+
cipher = Cipher(
|
|
71
|
+
algorithms.AES(base64.b64decode(self.key_base64)),
|
|
72
|
+
modes.CBC(iv),
|
|
73
|
+
backend=backend,
|
|
74
|
+
)
|
|
75
|
+
encryptor = cipher.encryptor()
|
|
76
|
+
padder = padding.PKCS7(algorithms.AES.block_size).padder()
|
|
77
|
+
padded_data = padder.update(string.encode()) + padder.finalize()
|
|
78
|
+
encrypted_data = encryptor.update(padded_data) + encryptor.finalize()
|
|
79
|
+
encrypted_data_base64 = base64.b64encode(iv + encrypted_data)
|
|
80
|
+
|
|
81
|
+
return encrypted_data_base64.decode()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|