powershell_pro_obfuscator_example_is_demo/powershell-pro-obfuscator-example-is-demo.rs
1/******************************************************************************
2 * PowerShell Pro Obfuscator WebApi interface usage example.
3 *
4 * In this example we will verify our activation key status.
5 *
6 * Version : v1.0.0
7 * Language : Rust
8 * Author : Bartosz Wójcik
9 * Web page : https://www.pelock.com
10 *
11 *****************************************************************************/
12
13use powershell_pro_obfuscator::{PowerShellProObfuscator, PowerShellProObfuscatorResponse};
14
15#[tokio::main]
16async fn main() -> Result<(), Box<dyn std::error::Error>> {
17 //
18 // include PowerShell Pro Obfuscator class
19 //
20
21 //
22 // if you don't want to use crates.io use a path dependency to this crate
23 //
24 // [dependencies]
25 // powershell-pro-obfuscator = { path = ".." }
26
27 //
28 // create PowerShell Pro Obfuscator class instance (we are using our activation key)
29 //
30 let my_powershell_pro_obfuscator =
31 PowerShellProObfuscator::new(Some("ABCD-ABCD-ABCD-ABCD".to_string()));
32
33 //
34 // login to the service
35 //
36 let result = my_powershell_pro_obfuscator.login(true).await;
37
38 //
39 // result object holds the information about the license
40 //
41 // result.demo - is it a demo mode (invalid or empty activation key was used)
42 // result.credits_left - usage credits left after this operation
43 // result.credits_total - total number of credits for this activation code
44 // result.string_limit - max. source code size allowed (it's 1000 bytes for demo mode)
45 //
46 match result {
47 Some(PowerShellProObfuscatorResponse::Object(obj)) => {
48 println!(
49 "Demo version status - {}",
50 if obj.demo.unwrap_or(false) {
51 "true"
52 } else {
53 "false"
54 }
55 );
56 println!(
57 "Usage credits left - {}",
58 obj.credits_left.unwrap_or(0)
59 );
60 println!(
61 "Total usage credits - {}",
62 obj.credits_total.unwrap_or(0)
63 );
64 println!(
65 "Max. source code size - {}",
66 obj.string_limit.unwrap_or(0)
67 );
68 }
69 Some(PowerShellProObfuscatorResponse::Json(_)) => {}
70 None => {
71 return Err("Something unexpected happen while trying to login to the service.".into());
72 }
73 }
74
75 Ok(())
76}