+fn get_exe_name() -> String {
+ let first_arg = std::env::args().nth(0).unwrap();
+ //dbg!(&first_arg);
+ let sep: &[_] = &['\\', '/'];
+ first_arg[first_arg.rfind(sep).unwrap()+1..].to_string()
+}
+
+fn print_usage() {
+ println!("Usage:");
+ println!(" {} [--help] [--encrypt <message>]", get_exe_name());
+}
+
+fn read_key() -> String {
+ use url::percent_encoding::percent_decode;
+ let mut key = String::new();
+ File::open(consts::FILE_KEY)
+ .expect(&format!("Failed to open key file: {}", consts::FILE_KEY))
+ .read_to_string(&mut key)
+ .expect(&format!("Failed to read key file: {}", consts::FILE_KEY));
+
+ String::from(
+ percent_decode(key.as_bytes())
+ .decode_utf8()
+ .expect(&format!("Failed to decode key file: {}", consts::FILE_KEY))
+ )
+}
+