mirror of
https://github.com/kristoferssolo/des-rs.git
synced 2026-02-25 04:58:17 +00:00
feat: add cli app
This commit is contained in:
21
des/src/main.rs
Normal file
21
des/src/main.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
mod args;
|
||||
|
||||
use crate::args::{Args, Operation};
|
||||
use clap::Parser;
|
||||
use des_lib::Des;
|
||||
|
||||
fn main() {
|
||||
let args = Args::parse();
|
||||
let des = Des::new(args.key.as_64());
|
||||
|
||||
match args.operation {
|
||||
Operation::Encrypt => {
|
||||
let ciphertext = des.encrypt(args.text.as_64());
|
||||
println!("{ciphertext:016X}");
|
||||
}
|
||||
Operation::Decrypt { output_format } => {
|
||||
let plaintext = des.decrypt(args.text.as_64());
|
||||
println!("{plaintext:016X}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user