1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
pub use clap::Parser;
#[derive(Parser, Debug)]
pub struct Cpal {
#[clap(subcommand)]
pub operation: Option<Operation>,
#[clap(short, long)]
pub version: bool,
}
#[derive(Debug, Clone, clap::Subcommand)]
pub enum Operation {
Caesar {
#[clap(short, long)]
string: Option<String>,
#[clap(short, long)]
bytes: Option<String>,
offset: i32,
#[arg(long)]
hex: bool,
#[clap(short, long)]
file: bool,
},
Xor {
#[clap(short, long)]
string: Option<String>,
#[clap(short, long)]
bytes: Option<String>,
#[arg(long)]
hex: bool,
#[clap(short, long)]
key: String,
},
}
pub fn parse_hex(s: &str) -> u8 {
u8::from_str_radix(s.split("0x").last().unwrap(), 16).unwrap()
}