Skip to main content

Educational Python implementation of the Data Encryption Standard (DES)

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

project_des-0.1.1.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

project_des-0.1.1-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file project_des-0.1.1.tar.gz.

File metadata

  • Download URL: project_des-0.1.1.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for project_des-0.1.1.tar.gz
Algorithm Hash digest
SHA256 94c29b1832be655d106c9b7797f076b93e243b517d40305b3bcd2fd1604cfcc7
MD5 dc311dd24576608307e7ee0647d12c2d
BLAKE2b-256 698a925730aeb4c698345e882d4ef2cbe55582f3525bff95bc0cef6c34aaf497

See more details on using hashes here.

File details

Details for the file project_des-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: project_des-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for project_des-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f325e2a8d96be04cc0fe9de3b9df8e8344beb615b3b6ea38fe3c6a8bef0dfe98
MD5 bdd48c9e1a5a677f1388df5416f39cf3
BLAKE2b-256 409ddd26ebc27e2262951beb9a40c12f1a8cc622707ad89fb00e1fc4328caae7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page