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'key'); 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.0.tar.gz (8.2 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.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: project_des-0.1.0.tar.gz
  • Upload date:
  • Size: 8.2 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.0.tar.gz
Algorithm Hash digest
SHA256 93e30fa4d01089f98f84439a1c21804e274428828000b965dfd354d0e19fa908
MD5 4d2bea94eece8dac066417e70bea2aa8
BLAKE2b-256 78b92322f2596617fb9fb8cd1308e466ce9200a39cc7f7bc54ffac6585eb9e37

See more details on using hashes here.

File details

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

File metadata

  • Download URL: project_des-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.1 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 39eb2e99929814f28de92a49b5a7aaae429422f6bc9b18898bc8f1c1d7f236eb
MD5 1ebca0a692a017ca7eef4e44102d730c
BLAKE2b-256 6403b1d9cf67fcfae2fe4b5f29f7f6c62d939e464c8322dcab23288092d90a3e

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