The project aims to help users to create PEM keys using a specific cryptography algorithm.
Below is the overview of the available functions:
$ key-generator --help
Usage: key-generator [OPTIONS]
Options:
--algorithm [rsa] Algorithm type [required]
--key_size INTEGER The output format keys. The default value is
2048 [required]
--format [open_ssl|decrypted_open_ssl]
The output format to be used. [required]
--help Show this message and exit.
Enjoy the program!
The application uses the design pattern MVP with the concepts of clean architecture. To do it I've used the package feature pattern and separated it as displayed below.
Technology | Description |
---|---|
cryptography | Perform cryptography operations |
click | Click is a Python package for creating beautiful command line interfaces |
pytest | The pytest framework makes it easy to write small tests |
pytest-cov | This plugin produces coverage tests reports |
pytest-html | This plugin produces a html tests reports |
unittest.mock | It is a framework that helps developers to mock, stub and spy the code under test. |
Technology | Description |
---|---|
pyCharm | The python IDE |
This project brings to table set of best practices, tools, and solutions:
- MVP + clean architecture
- 100% python
- Package feature pattern
- Testing (coverage + unit testing)
- CI integration by github actions
- static code analyse - TBD
The module key-generator
has 97% code coverage.
============================= test session starts ==============================
platform linux -- Python 3.9.1, pytest-6.2.1, py-1.10.0, pluggy-0.12.0
plugins: metadata-1.11.0, cov-2.10.1, pylama-7.7.1, html-3.1.1
collected 15 items
tests/test_create_rsa_keys_use_case.py ... [ 20%]
tests/test_dependency_factory.py .... [ 46%]
tests/test_key_generator_product.py . [ 53%]
tests/test_main_presenter.py . [ 60%]
tests/test_rsa_algorithm_impl.py . [ 66%]
tests/test_rsa_creator.py . [ 73%]
tests/test_rsa_repository.py .. [ 86%]
tests/test_rsa_source.py .. [100%]
----------- coverage: platform linux, python 3.9.1-final-0 -----------
Name Stmts Miss Cover
---------------------------------------------------------------------------------------------------
source/algorithm/__init__.py 0 0 100%
source/algorithm/asymmetric/__init__.py 0 0 100%
source/algorithm/asymmetric/asymmetric_algorithm_contract.py 7 1 86%
source/algorithm/asymmetric/rsa_feature/__init__.py 1 0 100%
source/algorithm/asymmetric/rsa_feature/data/__init__.py 2 0 100%
source/algorithm/asymmetric/rsa_feature/data/rsa_creator.py 5 0 100%
source/algorithm/asymmetric/rsa_feature/data/rsa_key_generator_product.py 8 0 100%
source/algorithm/asymmetric/rsa_feature/data/rsa_repository.py 9 0 100%
source/algorithm/asymmetric/rsa_feature/data/rsa_source.py 20 0 100%
source/algorithm/asymmetric/rsa_feature/impl/__init__.py 1 0 100%
source/algorithm/asymmetric/rsa_feature/impl/rsa_algorith_impl.py 10 0 100%
source/algorithm/asymmetric/rsa_feature/rsa_data_source_contract.py 18 4 78%
source/algorithm/asymmetric/rsa_feature/user_case/__init__.py 0 0 100%
source/algorithm/asymmetric/rsa_feature/user_case/create_rsa_keys_use_case.py 14 0 100%
source/algorithm/asymmetric/supported_asymmetric_algorithm.py 4 0 100%
source/algorithm/cryptography_algorithm_creator.py 5 1 80%
source/algorithm/cryptography_product.py 5 1 80%
source/main/__init__.py 2 0 100%
source/main/client_contract.py 13 2 85%
source/main/factory_dependencies.py 18 0 100%
source/main/presenter/__init__.py 1 0 100%
source/main/presenter/main_presenter.py 16 0 100%
source/shared/__init__.py 0 0 100%
source/shared/keys_entity.py 8 1 88%
tests/__init__.py 0 0 100%
tests/test_create_rsa_keys_use_case.py 32 0 100%
tests/test_dependency_factory.py 21 0 100%
tests/test_key_generator_product.py 5 0 100%
tests/test_main_presenter.py 16 0 100%
tests/test_rsa_algorithm_impl.py 16 0 100%
tests/test_rsa_creator.py 6 0 100%
tests/test_rsa_repository.py 16 0 100%
tests/test_rsa_source.py 13 0 100%
---------------------------------------------------------------------------------------------------
TOTAL 292 10 97%
============================== 15 passed in 0.24s ==============================
To run and install the app you must have the following specifications:
click==7.1.2
cryptography~=3.3.1
First of all you need to download a stable releases of the standalone cryptography-cli binaries here. After that you have two options to install:
To install it you must use the following command.
pip install key_generator_cli-X.X.X-py3-none-any.whl
Check if no error happens in the terminal and move to the next section.
To do it you must type the command pip install --editable .
in folder that will install it on your env python dependencies in developer mode.
Ps: This approach will remove the key_generator_cli from the path after it is closed.
After install it you can type key-generator --help
to get all information about the program.
Type the command key-generator --algorithm rs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GPslIy9Fs/wnvrCDdIcCVoXbCTW7Epi2JR/we6oD1nPcRJfx6nb6w==
Type the command key-generator --algorithm rsa --key_size 1024 --format decrypted_open_ssl
to get the generated decrypted RSA keys
-----BEGIN RSA PRIVATE KEY-----
MIICXAIBAAKBgQC8itpxBNPqpxzQicLZt6C03UYBQ8MTSBF2XKt8s/7amJxQn+Pe
Fe+6oKxmVmkKrr0mcDQFzypymtb9KUsCXN2mtZFj4AmyqULY9j84HiqL/E0TPJ6e
dSJ8Ey3u/LPMUkgpLJfDutscYLQbranMzOGmeeZPgnDAGqsjaq5BK7UqJQIDAQAB
AoGARGFz0lO27D8Jw1SDd+USgyZRknnaEW8s7im0BHlfsDZzUwZ6ZXy9QomtnTwv
wrEXZw6Av66gLYqc+Jp2WvgFZyYoS4Hv9eknN/UghKRB/oIYrpXoG1FQtxoGIsj1
E+Jg25+yRRJ+3dbEXMcVBRRpvdqAVfpa1rq4pIxoe7e7t0ECQQDwTDd6ZhA4ZjMj
/6H3WX4UuFQ++tImoLpwXUfp84WV2TT7G8dN8vS0TjKERw+/3Tzpvlopn0Vj+Ica
7sb1lScRAkEAyNzbCRLtDnZ36ha59GIRjgYQaz32UTL3iJY0P+8hA3HqayveN5go
/cmNUXmc6FMbuSrfOl9d5aF7nLvjtxsZ1QJAM9w/HOtqFMH5x4skKX3m+BHQHMeF
E1Ec66M2IgesjOqTxJ36JZiJt2ApBuNPQtk8jDXIv7LgBvNcNTPTPK00AQJBAIM6
j7v46nm1episqmb4n2F7osR94eyg8MoC4DYZBCedCDtmmLMXrUhJoxNk8ddzXLx4
PwmC/vSksP7wXlDl2tUCQHzDAqDt/0GkXzYb2d/4ADnY4xIyPrK8g8bodpSk58Rf
Z1S8+GjKO1XuHFZL8kVGC/RldTHgPdR2dXHiG2BHgmc=
-----END RSA PRIVATE KEY-----
-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8itpxBNPqpxzQicLZt6C03UYB
Q8MTSBF2XKt8s/7amJxQn+PeFe+6oKxmVmkKrr0mcDQFzypymtb9KUsCXN2mtZFj
4AmyqULY9j84HiqL/E0TPJ6edSJ8Ey3u/LPMUkgpLJfDutscYLQbranMzOGmeeZP
gnDAGqsjaq5BK7UqJQIDAQAB
-----END PUBLIC KEY-----
This section is related to the features/bug fixes of project.
I'd love if you contribute with the upcoming features or bug fixes. Go ahead and read the CONTRIBUTING file.
You can check it out for new features on github.
Follow me
Copyright (c) 2020 Thiago Lopes da Silva
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.