des-PurePy 1.0.9__tar.gz → 1.0.13__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,39 +1,46 @@
1
- # This workflow will install Python dependencies, run tests and lint with a single version of Python
2
- # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3
-
4
- name: DES-Python
5
-
6
- on:
7
- push:
8
- branches: [ "main" ]
9
- pull_request:
10
- branches: [ "main" ]
11
-
12
- permissions:
13
- contents: read
14
-
15
- jobs:
16
- build:
17
-
18
- runs-on: ubuntu-latest
19
-
20
- steps:
21
- - uses: actions/checkout@v4
22
- - name: Set up Python 3.10
23
- uses: actions/setup-python@v3
24
- with:
25
- python-version: "3.10"
26
- - name: Install dependencies
27
- run: |
28
- python -m pip install --upgrade pip
29
- pip install flake8 pytest des_PurePy
30
- if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
31
- - name: Lint with flake8
32
- run: |
33
- # stop the build if there are Python syntax errors or undefined names
34
- flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
35
- # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
36
- flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
37
- - name: Test with pytest
38
- run: |
39
- pytest
1
+ name: DES-Python
2
+
3
+ on:
4
+ push:
5
+ branches: [ "main" ]
6
+ pull_request:
7
+ branches: [ "main" ]
8
+
9
+ permissions:
10
+ contents: read
11
+
12
+ jobs:
13
+ build:
14
+
15
+ runs-on: ubuntu-latest
16
+
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+ - name: Set up Python 3.10
20
+ uses: actions/setup-python@v3
21
+ with:
22
+ python-version: "3.10"
23
+ - name: Install dependencies
24
+ run: |
25
+ python -m pip install --upgrade pip
26
+ pip install flake8 pytest des_PurePy ruff pyright
27
+ if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
28
+ - name: Lint with flake8
29
+ run: |
30
+ # stop the build if there are Python syntax errors or undefined names
31
+ flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
32
+ # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
33
+ flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
34
+ - name: Test with pytest
35
+ run: |
36
+ pytest
37
+ - name: Lint with Ruff
38
+ run: |
39
+ ruff check .
40
+ - name: Format with Ruff
41
+ run: |
42
+ ruff format --check .
43
+ - name: Type check with pyright
44
+ run: |
45
+ pyright .
46
+
@@ -0,0 +1,168 @@
1
+ name: release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "[0-9]+.[0-9]+.[0-9]+"
7
+ - "[0-9]+.[0-9]+.[0-9]+a[0-9]+"
8
+ - "[0-9]+.[0-9]+.[0-9]+b[0-9]+"
9
+ - "[0-9]+.[0-9]+.[0-9]+rc[0-9]+"
10
+
11
+ env:
12
+ PACKAGE_NAME: "<PACKAGE_NAME>"
13
+ OWNER: "<OWNER>"
14
+ TAP_NAME: "<TAP_NAME>"
15
+
16
+ jobs:
17
+ details:
18
+ runs-on: ubuntu-latest
19
+ outputs:
20
+ new_version: ${{ steps.release.outputs.new_version }}
21
+ suffix: ${{ steps.release.outputs.suffix }}
22
+ tag_name: ${{ steps.release.outputs.tag_name }}
23
+ steps:
24
+ - uses: actions/checkout@v2
25
+
26
+ - name: Extract tag and Details
27
+ id: release
28
+ run: |
29
+ if [ "${{ github.ref_type }}" = "tag" ]; then
30
+ TAG_NAME=${GITHUB_REF#refs/tags/}
31
+ NEW_VERSION=$(echo $TAG_NAME | awk -F'-' '{print $1}')
32
+ SUFFIX=$(echo $TAG_NAME | grep -oP '[a-z]+[0-9]+' || echo "")
33
+ echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
34
+ echo "suffix=$SUFFIX" >> "$GITHUB_OUTPUT"
35
+ echo "tag_name=$TAG_NAME" >> "$GITHUB_OUTPUT"
36
+ echo "Version is $NEW_VERSION"
37
+ echo "Suffix is $SUFFIX"
38
+ echo "Tag name is $TAG_NAME"
39
+ else
40
+ echo "No tag found"
41
+ exit 1
42
+ fi
43
+
44
+ check_pypi:
45
+ needs: details
46
+ runs-on: ubuntu-latest
47
+ steps:
48
+ - name: Fetch information from PyPI
49
+ run: |
50
+ response=$(curl -s https://pypi.org/pypi/${{ env.PACKAGE_NAME }}/json || echo "{}")
51
+ latest_previous_version=$(echo $response | jq --raw-output "select(.releases != null) | .releases | keys_unsorted | last")
52
+ if [ -z "$latest_previous_version" ]; then
53
+ echo "Package not found on PyPI."
54
+ latest_previous_version="0.0.0"
55
+ fi
56
+ echo "Latest version on PyPI: $latest_previous_version"
57
+ echo "latest_previous_version=$latest_previous_version" >> $GITHUB_ENV
58
+
59
+ - name: Compare versions and exit if not newer
60
+ run: |
61
+ NEW_VERSION=${{ needs.details.outputs.new_version }}
62
+ LATEST_VERSION=$latest_previous_version
63
+ if [ "$(printf '%s\n' "$LATEST_VERSION" "$NEW_VERSION" | sort -rV | head -n 1)" != "$NEW_VERSION" ] || [ "$NEW_VERSION" == "$LATEST_VERSION" ]; then
64
+ echo "The new version $NEW_VERSION is not greater than the latest version $LATEST_VERSION on PyPI."
65
+ exit 1
66
+ else
67
+ echo "The new version $NEW_VERSION is greater than the latest version $LATEST_VERSION on PyPI."
68
+ fi
69
+
70
+ setup_and_build:
71
+ needs: [details, check_pypi]
72
+ runs-on: ubuntu-latest
73
+ steps:
74
+ - uses: actions/checkout@v2
75
+
76
+ - name: Set up Python
77
+ uses: actions/setup-python@v4
78
+ with:
79
+ python-version: "3.12"
80
+
81
+ - name: Install Poetry
82
+ run: |
83
+ curl -sSL https://install.python-poetry.org | python3 -
84
+ echo "$HOME/.local/bin" >> $GITHUB_PATH
85
+
86
+ - name: Set project version with Poetry
87
+ run: |
88
+ poetry version ${{ needs.details.outputs.new_version }}
89
+
90
+ - name: Install dependencies
91
+ run: poetry sync --no-root --no-interaction
92
+
93
+ - name: Build source and wheel distribution
94
+ run: |
95
+ poetry build
96
+
97
+ - name: Upload artifacts
98
+ uses: actions/upload-artifact@v4
99
+ with:
100
+ name: dist
101
+ path: dist/
102
+
103
+ pypi_publish:
104
+ name: Upload release to PyPI
105
+ needs: [setup_and_build, details]
106
+ runs-on: ubuntu-latest
107
+ environment:
108
+ name: release
109
+ permissions:
110
+ id-token: write
111
+ steps:
112
+ - name: Download artifacts
113
+ uses: actions/download-artifact@v4
114
+ with:
115
+ name: dist
116
+ path: dist/
117
+
118
+ - name: Publish distribution to PyPI
119
+ uses: pypa/gh-action-pypi-publish@release/v1
120
+
121
+ github_release:
122
+ name: Create GitHub Release
123
+ needs: [setup_and_build, details]
124
+ runs-on: ubuntu-latest
125
+ permissions:
126
+ contents: write
127
+ steps:
128
+ - name: Checkout Code
129
+ uses: actions/checkout@v3
130
+ with:
131
+ fetch-depth: 0
132
+
133
+ - name: Download artifacts
134
+ uses: actions/download-artifact@v4
135
+ with:
136
+ name: dist
137
+ path: dist/
138
+
139
+ - name: Create GitHub Release
140
+ id: create_release
141
+ env:
142
+ GH_TOKEN: ${{ github.token }}
143
+ run: |
144
+ gh release create ${{ needs.details.outputs.tag_name }} dist/* --title ${{ needs.details.outputs.tag_name }} --generate-notes
145
+
146
+ bump_homebrew_formula:
147
+ name: Dispatch event to Repo B
148
+ needs: [details, github_release, pypi_publish]
149
+ runs-on: ubuntu-latest
150
+ environment:
151
+ name: release
152
+ steps:
153
+ - name: Dispatch Repository Dispatch event
154
+ uses: peter-evans/repository-dispatch@v2
155
+ with:
156
+ token: ${{ secrets.BREW_TAP_TOKEN }}
157
+ repository: ${{ env.OWNER }}/{{ env.TAP_NAME }}
158
+ event-type: "update-formula"
159
+ client-payload: |-
160
+ {
161
+ "formula_version": "${{env.FORMULA_VERSION}}",
162
+ "formula_url": "${{ env.FORMULA_URL }}",
163
+ "formula_name": "${{ env.FORMULA_NAME }}"
164
+ }
165
+ env:
166
+ FORMULA_VERSION: ${{ needs.details.outputs.new_version }}
167
+ FORMULA_NAME: ${{ env.PACKAGE_NAME }}
168
+ FORMULA_URL: https://github.com/${{env.OWNER}}/${{env.PACKAGE_NAME}}/releases/download/${{ needs.details.outputs.new_version }}/${{env.PACKAGE_NAME}}-${{ needs.details.outputs.new_version }}.tar.gz
File without changes
File without changes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: des_PurePy
3
- Version: 1.0.9
3
+ Version: 1.0.13
4
4
  Summary: A pure python implementation of DES
5
5
  Project-URL: Homepage, https://github.com/Perez-Herrera-Luna/DES-Python
6
6
  Author: Luna Perez-Herrera
@@ -16,6 +16,7 @@ Description-Content-Type: text/markdown
16
16
  ![made-with-python](https://img.shields.io/badge/Made%20with-Python%203-1f425f.svg)
17
17
  [![license: AGPL-3.0](https://img.shields.io/github/license/Perez-Herrera-Luna/DES-Python.svg)](https://github.com/Perez-Herrera-Luna/DES-Python/blob/main/LICENSE)
18
18
  [![DES-Python](https://github.com/Perez-Herrera-Luna/DES-Python/actions/workflows/python-app.yml/badge.svg)](https://github.com/Perez-Herrera-Luna/DES-Python/actions/workflows/python-app.yml)
19
+ [![PyPI Downloads](https://static.pepy.tech/personalized-badge/des-purepy?period=total&units=INTERNATIONAL_SYSTEM&left_color=BLACK&right_color=GREEN&left_text=downloads)](https://pepy.tech/projects/des-purepy)
19
20
 
20
21
  Data Encryption Standard (DES) implemented in pure Python
21
22
 
@@ -64,4 +65,4 @@ ciphertext = des.encrypt(b"secret message") # -> "0x0d417ca7d235
64
65
  cleartext = des.decrypt(ciphertext) # -> "0x736563726574206d657373616765"
65
66
  cleartext = bytes.fromhex(cleartext[2:]).decode("utf-8") # -> "secret message"
66
67
  ```
67
- Note that all input is validated so if you passing in an inapropriate input the module will raise a corresponding error.
68
+ Note that all input is validated so if you pass in an inapropriate input the module will raise a corresponding error.
@@ -1,54 +1,55 @@
1
- # DES-Python
2
-
3
- ![made-with-python](https://img.shields.io/badge/Made%20with-Python%203-1f425f.svg)
4
- [![license: AGPL-3.0](https://img.shields.io/github/license/Perez-Herrera-Luna/DES-Python.svg)](https://github.com/Perez-Herrera-Luna/DES-Python/blob/main/LICENSE)
5
- [![DES-Python](https://github.com/Perez-Herrera-Luna/DES-Python/actions/workflows/python-app.yml/badge.svg)](https://github.com/Perez-Herrera-Luna/DES-Python/actions/workflows/python-app.yml)
6
-
7
- Data Encryption Standard (DES) implemented in pure Python
8
-
9
- ![Demo](https://github.com/user-attachments/assets/aaa905df-d924-4d52-80f4-b06390c1b523)
10
-
11
- ## Features
12
-
13
- - **Encryption and Decryption**
14
- - **PKCS5 Padding**
15
- - **ECB Mode of Operation**
16
- - **Hex String and Bytes Object Support**
17
-
18
- ## Installation
19
-
20
- Install using your Python package manager of choice:
21
- ```bash
22
- pip install des_PurePy
23
- ```
24
-
25
- ## Usage
26
- ### Encrypting Hex Strings
27
- Define a `DES` object while passing in your key. The key can be a hex string or a bytes object.
28
- ```python
29
- import des_PurePy
30
- des = des_PurePy.DES("0x133457799bbcdff1")
31
- ```
32
- You can encrypt by calling `encrypt()` and passing in a hex string or bytes object.
33
- ```python
34
- des.encrypt("0x0123456789abcdef") # -> "0x85e813540f0ab405fdf2e174492922f8"
35
- ```
36
- You can simarly decrypt by calling `decrypt()` and passing in a hex string or bytes object.
37
- ```python
38
- des.decrypt("0x85e813540f0ab405fdf2e174492922f8") # -> "0x0123456789abcdef"
39
- ```
40
- By default, encryption input is padded to a multiple of the block size (8 bytes) according to PKCS5. Inputs that are multiple blocks long are encrypted using the Electronic Code Book (ECB) mode of operation.
41
- ### Encrypting Bytes Objects and Text
42
- Inputs can be hex strings or bytes objects. The key must always be 8 bytes but the encryption input can have any size.
43
- Because of the bytes object support, with some work, you can encrypt and decrypt text.
44
- ```python
45
- import des_PurePy
46
-
47
- key = b"password"
48
- des = des_PurePy.DES(key)
49
-
50
- ciphertext = des.encrypt(b"secret message") # -> "0x0d417ca7d23582bab5e2c9277f801591"
51
- cleartext = des.decrypt(ciphertext) # -> "0x736563726574206d657373616765"
52
- cleartext = bytes.fromhex(cleartext[2:]).decode("utf-8") # -> "secret message"
53
- ```
54
- Note that all input is validated so if you passing in an inapropriate input the module will raise a corresponding error.
1
+ # DES-Python
2
+
3
+ ![made-with-python](https://img.shields.io/badge/Made%20with-Python%203-1f425f.svg)
4
+ [![license: AGPL-3.0](https://img.shields.io/github/license/Perez-Herrera-Luna/DES-Python.svg)](https://github.com/Perez-Herrera-Luna/DES-Python/blob/main/LICENSE)
5
+ [![DES-Python](https://github.com/Perez-Herrera-Luna/DES-Python/actions/workflows/python-app.yml/badge.svg)](https://github.com/Perez-Herrera-Luna/DES-Python/actions/workflows/python-app.yml)
6
+ [![PyPI Downloads](https://static.pepy.tech/personalized-badge/des-purepy?period=total&units=INTERNATIONAL_SYSTEM&left_color=BLACK&right_color=GREEN&left_text=downloads)](https://pepy.tech/projects/des-purepy)
7
+
8
+ Data Encryption Standard (DES) implemented in pure Python
9
+
10
+ ![Demo](https://github.com/user-attachments/assets/aaa905df-d924-4d52-80f4-b06390c1b523)
11
+
12
+ ## Features
13
+
14
+ - **Encryption and Decryption**
15
+ - **PKCS5 Padding**
16
+ - **ECB Mode of Operation**
17
+ - **Hex String and Bytes Object Support**
18
+
19
+ ## Installation
20
+
21
+ Install using your Python package manager of choice:
22
+ ```bash
23
+ pip install des_PurePy
24
+ ```
25
+
26
+ ## Usage
27
+ ### Encrypting Hex Strings
28
+ Define a `DES` object while passing in your key. The key can be a hex string or a bytes object.
29
+ ```python
30
+ import des_PurePy
31
+ des = des_PurePy.DES("0x133457799bbcdff1")
32
+ ```
33
+ You can encrypt by calling `encrypt()` and passing in a hex string or bytes object.
34
+ ```python
35
+ des.encrypt("0x0123456789abcdef") # -> "0x85e813540f0ab405fdf2e174492922f8"
36
+ ```
37
+ You can simarly decrypt by calling `decrypt()` and passing in a hex string or bytes object.
38
+ ```python
39
+ des.decrypt("0x85e813540f0ab405fdf2e174492922f8") # -> "0x0123456789abcdef"
40
+ ```
41
+ By default, encryption input is padded to a multiple of the block size (8 bytes) according to PKCS5. Inputs that are multiple blocks long are encrypted using the Electronic Code Book (ECB) mode of operation.
42
+ ### Encrypting Bytes Objects and Text
43
+ Inputs can be hex strings or bytes objects. The key must always be 8 bytes but the encryption input can have any size.
44
+ Because of the bytes object support, with some work, you can encrypt and decrypt text.
45
+ ```python
46
+ import des_PurePy
47
+
48
+ key = b"password"
49
+ des = des_PurePy.DES(key)
50
+
51
+ ciphertext = des.encrypt(b"secret message") # -> "0x0d417ca7d23582bab5e2c9277f801591"
52
+ cleartext = des.decrypt(ciphertext) # -> "0x736563726574206d657373616765"
53
+ cleartext = bytes.fromhex(cleartext[2:]).decode("utf-8") # -> "secret message"
54
+ ```
55
+ Note that all input is validated so if you pass in an inapropriate input the module will raise a corresponding error.
File without changes
@@ -0,0 +1,7 @@
1
+ # This file is automatically @generated by Poetry 2.4.1 and should not be changed by hand.
2
+ package = []
3
+
4
+ [metadata]
5
+ lock-version = "2.1"
6
+ python-versions = ">=3.9"
7
+ content-hash = "356ea28cc0a224833d10ed4e84359208ee6800e346fb0b9d2f6e4702658123d1"
@@ -1,25 +1,25 @@
1
- [project]
2
- name = "des_PurePy"
3
- version = "1.0.9"
4
- authors = [
5
- { name="Luna Perez-Herrera"}
6
- ]
7
- description = "A pure python implementation of DES"
8
- readme = "README.md"
9
- requires-python = ">=3.9"
10
- classifiers = [
11
- "Programming Language :: Python :: 3",
12
- "Operating System :: OS Independent",
13
- ]
14
- license = "AGPL-3.0-only"
15
- license-files = ["LICEN[CS]E*"]
16
-
17
- [project.urls]
18
- Homepage = "https://github.com/Perez-Herrera-Luna/DES-Python"
19
-
20
- [build-system]
21
- requires = ["hatchling >= 1.26"]
22
- build-backend = "hatchling.build"
23
-
24
- [tool.pytest]
25
- testpaths = ["tests"]
1
+ [project]
2
+ name = "des_PurePy"
3
+ version = "1.0.13"
4
+ authors = [
5
+ { name="Luna Perez-Herrera"}
6
+ ]
7
+ description = "A pure python implementation of DES"
8
+ readme = "README.md"
9
+ requires-python = ">=3.9"
10
+ classifiers = [
11
+ "Programming Language :: Python :: 3",
12
+ "Operating System :: OS Independent",
13
+ ]
14
+ license = "AGPL-3.0-only"
15
+ license-files = ["LICEN[CS]E*"]
16
+
17
+ [project.urls]
18
+ Homepage = "https://github.com/Perez-Herrera-Luna/DES-Python"
19
+
20
+ [build-system]
21
+ requires = ["hatchling >= 1.26"]
22
+ build-backend = "hatchling.build"
23
+
24
+ [tool.pytest]
25
+ testpaths = ["tests"]
@@ -0,0 +1,5 @@
1
+ """Package providing a DES implementation."""
2
+
3
+ from .des import DES as DES
4
+
5
+ # Import class DES from module (file) DES. Simplies user import
@@ -126,16 +126,16 @@ class DES:
126
126
  plaintext = self.__permute(plaintext, self.__ip)
127
127
 
128
128
  # Split into two halves
129
- l = [plaintext[:32]]
130
- r = [plaintext[32:]]
129
+ left = [plaintext[:32]]
130
+ right = [plaintext[32:]]
131
131
 
132
132
  # Perform 16 rounds of DES
133
133
  for i in range(16):
134
- l.append(r[i])
135
- r.append(self.__xor(l[i], self.__f(r[i], self.__round_keys[i])))
134
+ left.append(right[i])
135
+ right.append(self.__xor(left[i], self.__f(right[i], self.__round_keys[i])))
136
136
 
137
137
  # Preform final permutation
138
- ciphertext = self.__permute(r[16] + l[16], self.__fp)
138
+ ciphertext = self.__permute(right[16] + left[16], self.__fp)
139
139
 
140
140
  return self.__format_binary_string_as_hex(ciphertext)
141
141
 
@@ -146,16 +146,18 @@ class DES:
146
146
  ciphertext = self.__permute(ciphertext, self.__ip)
147
147
 
148
148
  # Split into two halves
149
- l = [ciphertext[:32]]
150
- r = [ciphertext[32:]]
149
+ left = [ciphertext[:32]]
150
+ right = [ciphertext[32:]]
151
151
 
152
152
  # Perform 16 rounds of DES
153
153
  for i in range(16):
154
- l.append(r[i])
155
- r.append(self.__xor(l[i], self.__f(r[i], self.__round_keys_reversed[i])))
154
+ left.append(right[i])
155
+ right.append(
156
+ self.__xor(left[i], self.__f(right[i], self.__round_keys_reversed[i]))
157
+ )
156
158
 
157
159
  # Preform final permutation
158
- cleartext = self.__permute(r[16] + l[16], self.__fp)
160
+ cleartext = self.__permute(right[16] + left[16], self.__fp)
159
161
 
160
162
  return self.__format_binary_string_as_hex(cleartext)
161
163
 
@@ -1,3 +0,0 @@
1
- """Package providing a DES implementation."""
2
-
3
- from .des import DES # Import class DES from module (file) DES. Simplies user import