Skip to content

Commit

Permalink
Fix command line argument for string encryption percentage
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasscharenbroch committed Jan 15, 2024
1 parent 32aa4c9 commit 8598e4c
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions auto_obfuscate/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ fn main() {
.help("disable macro and modify source directly for flow obfuscation")
)
.arg(Arg::with_name("var").long("var").help("Enable variable renaming"))
.arg(Arg::with_name("p").long("p").help("set upper bound for string literal encryption"))
.arg(Arg::with_name("p")
.short('p')
.long("percent_strings_to_encrypt")
.help("set upper bound for string literal encryption")
.value_name("PERCENTAGE"))
.get_matches();

let path = matches.value_of("path").unwrap();
Expand All @@ -53,7 +57,14 @@ fn main() {
}
//set upper bound for string literal encryption
if let Some(percentage) = matches.value_of("p") {
config.string_config.percentage = percentage.parse().unwrap_or(100);
config.string_config.percentage = match percentage.parse() {
Ok(n) if n <= 100 => n,
_ => {
eprintln!("-p: expected integer between 0 and 100, got: `{}`", percentage);
eprintln!("defaulting to 100%");
100
}
};
}

process_path(&path, &config);
Expand Down

0 comments on commit 8598e4c

Please sign in to comment.