Add a way ton encrypt a message.
/target
**/*.rs.bk
+key.secret
+WebSharper/key
"winreg 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
+[[package]]
+name = "itertools"
+version = "0.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
[[package]]
name = "itoa"
version = "0.4.4"
"actix-files 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-web 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"askama 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"listenfd 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"openssl 0.10.23 (registry+https://github.com/rust-lang/crates.io-index)",
"ron 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d"
"checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08"
"checksum ipconfig 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aa79fa216fbe60834a9c0737d7fcd30425b32d1c58854663e24d4c4b328ed83f"
+"checksum itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b8467d9c1cebe26feb08c640139247fac215782d35371ade9a2136ed6085358"
"checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f"
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
"checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a"
openssl = "0.10"
listenfd = "0.3" # To watch file modifications and automatically launch a build process (only used in dev/debug).
-ron = "0.5.1" # Rust object notation, to load configuration files.
\ No newline at end of file
+ron = "0.5.1" # Rust object notation, to load configuration files.
+itertools = "0.8.0"
\ No newline at end of file
-* Use a setting file.\r
-* Enable Logging.
\ No newline at end of file
+* Enable Logging.\r
+\r
+[ok] Accept an argument to encrypt a message\r
+[ok] Use a setting file.
\ No newline at end of file
--- /dev/null
+cargo run --release -- --encrypt $args[0]
\ No newline at end of file
use ron::de::from_reader;
use serde::Deserialize;
-use std::fs::File;
+use std::{fs::File, env::args};
+
+use itertools::Itertools;
mod consts;
mod crypto;
port: u16
}
+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 main() -> std::io::Result<()> {
- println!("Starting RUP...");
+ let args: Vec<String> = args().collect();
+
+ if args.iter().any(|arg| arg == "--help") {
+ print_usage();
+ return Ok(());
+ } else if let Some((position_arg_encrypt, _)) = args.iter().find_position(|arg| arg == &"--encrypt") {
+ match args.iter().nth(position_arg_encrypt + 1) {
+ Some(mess_to_encrypt) => {
+ let encrypted_mess = mess_to_encrypt;
+ //let encrypted_mess = crypto::encrypt(key: &str, plain_text: &str);
+ println!("Encrypted message: {}", encrypted_mess);
+ }
+ None => print_usage()
+ }
+
+ return Ok(());
+ }
+
+ println!("Starting RUP as web server...");
let config: Config = {
let f = File::open(consts::FILE_CONF).expect(&format!("Failed to open configuration file {}", consts::FILE_CONF));
}
};
+ let key = File::open(consts::FILE_KEY).expect(&format!("Failed to open key file: {}", consts::FILE_KEY));
+
println!("Configuration: {:?}", config);
let mut listenfd = ListenFd::from_env();