mirror of
https://github.com/kristoferssolo/cipher-workshop.git
synced 2026-03-22 00:26:19 +00:00
feat(cipher-factory,cli): add CBC mode support to CipherContext and CLI
Update CipherContext:
- Add optional iv field for CBC mode
- Add process_cbc() for CBC-specific handling
- Add parse_hex() helper for decryption input
- Separate ECB and CBC processing paths
Update CLI:
- Add --iv argument for initialization vector
- Pass IV through to CipherContext
This commit is contained in:
@@ -12,11 +12,15 @@ pub struct Args {
|
||||
#[arg(short, long)]
|
||||
pub algorithm: Algorithm,
|
||||
|
||||
/// Key used for encryption/decryption. Can be a string or a path to a file
|
||||
/// Key used for encryption/decryption (hex string, e.g., 0x2b7e...)
|
||||
#[arg(short, long, required = true)]
|
||||
pub key: String,
|
||||
|
||||
/// The text to encrypt/decrypt. Can be a string or a path to a file
|
||||
/// Initialization vector for CBC mode (hex string, e.g., 0x0001...)
|
||||
#[arg(long)]
|
||||
pub iv: Option<String>,
|
||||
|
||||
/// The text to encrypt/decrypt
|
||||
#[arg(value_name = "TEXT", required = true)]
|
||||
pub text: String,
|
||||
|
||||
@@ -31,6 +35,7 @@ impl From<Args> for CipherContext {
|
||||
algorithm: args.algorithm,
|
||||
operation: args.operation,
|
||||
key: args.key,
|
||||
iv: args.iv,
|
||||
input_text: args.text,
|
||||
output_format: args.output_format.unwrap_or_default(),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user