mirror of
https://github.com/kristoferssolo/cipher-workshop.git
synced 2026-01-14 04:36:04 +00:00
refactor: rename CLI to crypt and remove ECB terminology
Some checks failed
CI / build-and-test (push) Has been cancelled
Some checks failed
CI / build-and-test (push) Has been cancelled
This commit is contained in:
parent
4f90912a4d
commit
dac009af1b
22
README.md
22
README.md
@ -4,8 +4,8 @@ A Rust workspace containing implementations of various cipher algorithms, along
|
|||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- **AES Implementation**: AES-128 in ECB and CBC modes
|
- **AES Implementation**: AES-128 block cipher and CBC mode
|
||||||
- **DES Implementation**: DES in ECB mode
|
- **DES Implementation**: DES block cipher
|
||||||
- **Command-Line Interface**: Encrypt and decrypt messages or files using the supported ciphers
|
- **Command-Line Interface**: Encrypt and decrypt messages or files using the supported ciphers
|
||||||
- **Web Interface**: Browser-based encryption with file upload, drag-and-drop, and random key/IV generation
|
- **Web Interface**: Browser-based encryption with file upload, drag-and-drop, and random key/IV generation
|
||||||
|
|
||||||
@ -13,10 +13,10 @@ A Rust workspace containing implementations of various cipher algorithms, along
|
|||||||
|
|
||||||
The `cipher-workshop` workspace is organized into the following crates:
|
The `cipher-workshop` workspace is organized into the following crates:
|
||||||
|
|
||||||
- `aes`: Implementation of the AES cipher (ECB and CBC modes)
|
- `aes`: Implementation of the AES cipher (block cipher and CBC mode)
|
||||||
- `cipher-core`: Core traits and types for ciphers
|
- `cipher-core`: Core traits and types for ciphers
|
||||||
- `cipher-factory`: A factory for creating cipher contexts
|
- `cipher-factory`: A factory for creating cipher contexts
|
||||||
- `cli`: A command-line interface for the ciphers
|
- `crypt`: A command-line interface for the ciphers
|
||||||
- `des`: Implementation of the DES cipher
|
- `des`: Implementation of the DES cipher
|
||||||
- `web`: A web interface built with Leptos
|
- `web`: A web interface built with Leptos
|
||||||
|
|
||||||
@ -44,34 +44,34 @@ cargo build
|
|||||||
|
|
||||||
The CLI allows you to encrypt and decrypt messages or files using the supported ciphers.
|
The CLI allows you to encrypt and decrypt messages or files using the supported ciphers.
|
||||||
|
|
||||||
#### AES (ECB mode)
|
#### AES (block mode)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Encrypt a message
|
# Encrypt a message
|
||||||
cargo run --bin cli -- encrypt -a aes -k 0x2B7E151628AED2A6ABF7158809CF4F3C "Hello World"
|
cargo run --bin crypt -- encrypt -a aes -k 0x2B7E151628AED2A6ABF7158809CF4F3C "Hello World"
|
||||||
|
|
||||||
# Decrypt a message
|
# Decrypt a message
|
||||||
cargo run --bin cli -- decrypt -a aes -k 0x2B7E151628AED2A6ABF7158809CF4F3C 0x...
|
cargo run --bin crypt -- decrypt -a aes -k 0x2B7E151628AED2A6ABF7158809CF4F3C 0x...
|
||||||
```
|
```
|
||||||
|
|
||||||
#### AES-CBC (with IV)
|
#### AES-CBC (with IV)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Encrypt a file
|
# Encrypt a file
|
||||||
cargo run --bin cli -- encrypt -a aes-cbc -k 0x2B7E151628AED2A6ABF7158809CF4F3C --iv 0x000102030405060708090A0B0C0D0E0F -i input.txt -o output.enc
|
cargo run --bin crypt -- encrypt -a aes-cbc -k 0x2B7E151628AED2A6ABF7158809CF4F3C --iv 0x000102030405060708090A0B0C0D0E0F -i input.txt -o output.enc
|
||||||
|
|
||||||
# Decrypt a file
|
# Decrypt a file
|
||||||
cargo run --bin cli -- decrypt -a aes-cbc -k 0x2B7E151628AED2A6ABF7158809CF4F3C --iv 0x000102030405060708090A0B0C0D0E0F -i output.enc -o decrypted.txt
|
cargo run --bin crypt -- decrypt -a aes-cbc -k 0x2B7E151628AED2A6ABF7158809CF4F3C --iv 0x000102030405060708090A0B0C0D0E0F -i output.enc -o decrypted.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
#### DES
|
#### DES
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Encrypt a message
|
# Encrypt a message
|
||||||
cargo run --bin cli -- encrypt -a des -k 0x133457799BBCDFF1 "Hello"
|
cargo run --bin crypt -- encrypt -a des -k 0x133457799BBCDFF1 "Hello"
|
||||||
|
|
||||||
# Decrypt a message
|
# Decrypt a message
|
||||||
cargo run --bin cli -- decrypt -a des -k 0x133457799BBCDFF1 0x...
|
cargo run --bin crypt -- decrypt -a des -k 0x133457799BBCDFF1 0x...
|
||||||
```
|
```
|
||||||
|
|
||||||
### Web Interface
|
### Web Interface
|
||||||
|
|||||||
@ -21,7 +21,7 @@ impl Algorithm {
|
|||||||
matches!(self, Self::AesCbc)
|
matches!(self, Self::AesCbc)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new ECB-mode cipher instance for the specified algorithm.
|
/// Creates a new block cipher instance for the specified algorithm.
|
||||||
///
|
///
|
||||||
/// Parses the key string and instantiates either DES or AES based on the algorithm choice.
|
/// Parses the key string and instantiates either DES or AES based on the algorithm choice.
|
||||||
/// The key format depends on the algorithm:
|
/// The key format depends on the algorithm:
|
||||||
@ -111,7 +111,7 @@ impl Algorithm {
|
|||||||
/// - The text length doesn't match the block size
|
/// - The text length doesn't match the block size
|
||||||
/// - The text contains invalid characters for the given format
|
/// - The text contains invalid characters for the given format
|
||||||
///
|
///
|
||||||
/// Parses text for ECB-mode algorithms (single block).
|
/// Parses text for block cipher algorithms (single block).
|
||||||
///
|
///
|
||||||
/// For CBC mode, use raw bytes directly instead of this method.
|
/// For CBC mode, use raw bytes directly instead of this method.
|
||||||
pub fn parse_text(&self, text: &str) -> Result<Vec<u8>, BlockError> {
|
pub fn parse_text(&self, text: &str) -> Result<Vec<u8>, BlockError> {
|
||||||
|
|||||||
@ -17,8 +17,7 @@ pub fn Home() -> impl IntoView {
|
|||||||
<p>
|
<p>
|
||||||
"A legacy algorithm from the 1970s. While historically significant, "
|
"A legacy algorithm from the 1970s. While historically significant, "
|
||||||
"it is now considered insecure due to its short 56-bit key length. "
|
"it is now considered insecure due to its short 56-bit key length. "
|
||||||
"This tool uses " <strong>"DES-ECB"</strong>
|
"This tool provides DES block encryption for educational purposes."
|
||||||
" mode for educational purposes."
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -26,7 +25,7 @@ pub fn Home() -> impl IntoView {
|
|||||||
<h3>"AES (Advanced Encryption Standard)"</h3>
|
<h3>"AES (Advanced Encryption Standard)"</h3>
|
||||||
<p>
|
<p>
|
||||||
"The modern standard for symmetric encryption. This tool offers "
|
"The modern standard for symmetric encryption. This tool offers "
|
||||||
<strong>"AES-128-ECB"</strong> " for single-block operations and "
|
<strong>"AES-128"</strong> " for single-block operations and "
|
||||||
<strong>"AES-128-CBC"</strong> " for encrypting arbitrary data with "
|
<strong>"AES-128-CBC"</strong> " for encrypting arbitrary data with "
|
||||||
"PKCS#7 padding."
|
"PKCS#7 padding."
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user