forked from rustdesk/rustdesk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnaming.rs
40 lines (38 loc) · 929 Bytes
/
naming.rs
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
mod license;
use hbb_common::ResultType;
use license::*;
fn gen_name(lic: &License) -> ResultType<String> {
let tmp = serde_json::to_vec::<License>(lic)?;
let tmp = base64::encode_config(tmp, base64::URL_SAFE_NO_PAD);
let tmp: String = tmp.chars().rev().collect();
Ok(tmp)
}
fn main() {
let mut args = Vec::new();
let mut i = 0;
for arg in std::env::args() {
if i > 0 {
args.push(arg);
}
i += 1;
}
let api = if args.len() < 3 {
"".to_owned()
} else {
args[2].clone()
};
if args.len() >= 2 {
println!(
"rustdesk-licensed-{}.exe",
gen_name(&License {
key: args[0].clone(),
host: args[1].clone(),
api,
})
.unwrap()
);
}
if args.len() == 1 {
println!("{:?}", get_license_from_string(&args[0]));
}
}