Skip to content

Commit

Permalink
refactor: 💡 replace pycrypto with pycryptodome
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhaoQi99 committed Apr 6, 2022
1 parent 1446897 commit ee3081f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
if [ -f dev-requirements.txt ]; then pip install -r dev-requirements.txt; fi
pip install --upgrade pip
pip install setuptools==57.5.0
pip install flake8 pytest
pip install .
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[build-system]
requires = [
"setuptools>=42",
"setuptools >= 42, < 58",
"wheel"
]
build-backend = "setuptools.build_meta"
2 changes: 1 addition & 1 deletion requirement.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
click==8.0.3
Cython==0.29.24
pycrypto==2.6.1
pycryptodome==3.14.1
pyminifier==2.1
7 changes: 4 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ classifiers =
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: Implementation :: CPython
Environment :: Console
license_files = LICENSE
Expand All @@ -28,9 +29,9 @@ keywords = python-encrypt, import-hook

[options]
install_requires =
Cython
pycrypto
pyminifier
Cython >= 0.29.24
pycryptodome >= 3.14.1
pyminifier >= 2.1
click
python_requires = >=3.6
packages = find:
Expand Down
6 changes: 3 additions & 3 deletions tests/test_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_generate_aes_key(size):
assert isinstance(generate_aes_key(size), bytes)


@pytest.mark.parametrize('bits', [1024, 2048, 4096])
@pytest.mark.parametrize('bits', [1024, 1025, 2045, 2048, 4096])
def test_generate_rsa_number(bits):
numbers = generate_rsa_number(bits)
assert len(numbers) == 5
Expand All @@ -24,8 +24,8 @@ def test_generate_rsa_number(bits):
assert pow(pow(plain, e, n), d, n) == plain


@pytest.mark.parametrize('bits', [123, 456, 789])
@pytest.mark.parametrize('bits', [-1, 123])
def test_generate_rsa_number_exception(bits):
with pytest.raises(ValueError) as excinfo:
generate_rsa_number(bits)
assert str(excinfo.value) == "RSA modulus length must be a multiple of 256 and >= 1024"
assert str(excinfo.value) == "RSA modulus length must be >= 1024"

0 comments on commit ee3081f

Please sign in to comment.