Warning: This implementation is intended for self learning purposes only and should not be used for real-world security.
About
- Author: shrimp2845
- Version: 0.1.0
- License: MIT
This is an educational Python implementation of the Data Encryption Standard (DES). This project breaks down the complex Feistel network into human-readable modules following the official NIST specifications, and supports ECB and CBC modes for real file encryption.
Installation & Usage
install
Requires Python 3.10+
pip install project-des
usage
python -c "from project_DES import DES; cipher = DES(b'12345678'); print(cipher.encrypt(b'data').hex())"
Docs
class initialize
----------------------
project_DES.DES(key, mode='ECB')
key
-> 8 bytes or key file name
containing an encryption key,
if key is str, it extract
first 8 bytes in the file
mode
-> optional, block cipher mode of
operation that used,ECB and CBC
available in current version
methods
----------------------
encrypt(data: bytes) -> bytes,
decrypt(data: bytes) -> bytes
-> return encrypt/decrypt bytes data
encrypt_file(name: str, new_name: str),
decrypt_file(name: str, new_name: str)
-> encrypt/decrypt target file 'name'
and save it as 'new_name'
get_key(), get_mode()
-> get current using key/mode of
operation
change_key(key: str or bytes),
change_mode(mode: str)
-> change current using key/mode of
operation
Examples
Project provides two examples: string_cipher.py & file_cipher.py
you can find samples of file_cipher.py at: ecb_sample & cbc_sample
explanation for samples
mumei.jpg: plaintext file
mumei.bin: encrypt mumei.jpg with key ‘berries’ and mode ECB
mumei_correct_decrypt.jpg: decrypt mumei.bin with key ‘berries’ and mode ECB
mumei_wrong_decrypt.jpg: decrypt mumei.bin with key ‘friend’ and mode ECB
ina.jpg: plaintext file
ina.bin: encrypt ina.jpg with key ‘takodachi’ and mode CBC
ina_correct_decrypt.jpg: decrypt ina.bin with key ‘takodachi’ and mode CBC
ina_wrong_decrypt.jpg: decrypt ina.bin with key ‘violet’ and mode CBC
Performance
This project is designed for learning and understanding how DES works rather than for practical encryption use. The implementation prioritizes readability and modular structure over performance.
As a result, encryption process is very slow. It takes nearly 2 minutes to encrypt 1MB file.
Metadata
Release files for project-des 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| project_des-0.1.1.tar.gz | 8.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| project_des-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.9 kB
Release files / project_des-0.1.1.tar.gz
| Download URL | project_des-0.1.1.tar.gz |
|---|---|
| Size | 8.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
94c29b1832be655d106c9b7797f076b93e243b517d40305b3bcd2fd1604cfcc7
|
|
BLAKE2b-256 checksum How to use checksums |
698a925730aeb4c698345e882d4ef2cbe55582f3525bff95bc0cef6c34aaf497
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.12
|
Release files / project_des-0.1.1-py3-none-any.whl
| Download URL | project_des-0.1.1-py3-none-any.whl |
|---|---|
| Size | 10.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f325e2a8d96be04cc0fe9de3b9df8e8344beb615b3b6ea38fe3c6a8bef0dfe98
|
|
BLAKE2b-256 checksum How to use checksums |
409ddd26ebc27e2262951beb9a40c12f1a8cc622707ad89fb00e1fc4328caae7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.12
|