Simplified Data Encryption Standard (S-DES) Implementation
Project description
S-DES (Simplified Data Encryption Standard)
S-DES (Simplified Data Encryption Standard) is a lightweight block cipher that operates on 8-bit blocks. This package implements the encryption and decryption functionality of S-DES using a 10-bit key.
Installation
To install the package, you can use the following pip command:
pip install sdes
pip install bitarray
If you are developing locally, you can install the package in editable mode:
pip install -e .
Usage
You can use this package to perform encryption and decryption using the Simplified Data Encryption Standard (S-DES) algorithm.
Example Usage
from sdes import encrypt, decrypt, generate_keys
import bitarray
# Example 10-bit key (must be 10-bits long)
key = bitarray.bitarray('1010000010')
# Example 8-bit plaintext (must be 8-bits long)
plaintext = bitarray.bitarray('11010011')
# Generate subkeys
key1, key2 = generate_keys(key)
# Encrypt the plaintext
ciphertext = encrypt(plaintext, key1, key2)
print("Encrypted:", ciphertext)
# Decrypt the ciphertext
decrypted_text = decrypt(ciphertext, key1, key2)
print("Decrypted:", decrypted_text)
Functions
-
generate_keys(key)
Generates two 8-bit subkeys (key1andkey2) from the provided 10-bit key.Parameters:
key(bitarray): The 10-bit key.
Returns:
key1(bitarray): First subkey.key2(bitarray): Second subkey.
-
encrypt(plaintext, key1, key2)
Encrypts the 8-bitplaintextusing the two subkeys (key1andkey2) according to the S-DES algorithm.Parameters:
plaintext(bitarray): The 8-bit plaintext to encrypt.key1(bitarray): First subkey.key2(bitarray): Second subkey.
Returns:
ciphertext(bitarray): The encrypted 8-bit ciphertext.
-
decrypt(ciphertext, key1, key2)
Decrypts the 8-bitciphertextusing the two subkeys (key1andkey2) according to the S-DES algorithm.Parameters:
ciphertext(bitarray): The 8-bit ciphertext to decrypt.key1(bitarray): First subkey.key2(bitarray): Second subkey.
Returns:
decrypted_text(bitarray): The decrypted 8-bit plaintext.
Requirements
This package requires the following libraries:
bitarray: A Python module for efficiently working with bit arrays.numpy: A package for numerical computations (optional for your case but can be useful for optimization).
You can install the dependencies using:
pip install bitarray numpy
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Feel free to open issues and submit pull requests. Contributions are welcome!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sdes-0.1.3.tar.gz.
File metadata
- Download URL: sdes-0.1.3.tar.gz
- Upload date:
- Size: 3.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af14edd2cede31e1f5738df8d9310cd2f15d8b7600b39a819c1743ada1cc0b36
|
|
| MD5 |
01192516118202be78a66de0b983f440
|
|
| BLAKE2b-256 |
a06a60a87346fde9b85c4a48c2f60c191e796f2fd2560929b70d087e22e8a3d5
|
File details
Details for the file sdes-0.1.3-py3-none-any.whl.
File metadata
- Download URL: sdes-0.1.3-py3-none-any.whl
- Upload date:
- Size: 3.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
91e673adea1621294ac790b866dbc1e82172d346da58959e62485e38eb53f2a6
|
|
| MD5 |
2bb40d943fb783f11c23edfa5958ae4b
|
|
| BLAKE2b-256 |
4ac2ccb6e1b251e6d3e956f64effbabed51fd40734cd0d7ba6b205c0c13bd619
|