python_obfuscator_example_is_demo/python-obfuscator-example-is-demo.rs
1/******************************************************************************
2 * Python 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 python_obfuscator::{PythonObfuscator, PythonObfuscatorResponse};
14
15#[tokio::main]
16async fn main() -> Result<(), Box<dyn std::error::Error>> {
17 //
18 // include Python 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 // python-obfuscator = { path = ".." }
26
27 //
28 // create Python Obfuscator class instance (we are using our activation key)
29 //
30 let my_python_obfuscator =
31 PythonObfuscator::new(Some("ABCD-ABCD-ABCD-ABCD".to_string()));
32
33 //
34 // login to the service
35 //
36 let result = my_python_obfuscator.login(true).await;
37
38 //
39 // result object holds the information about the license
40 //
41 // result.demo - demo mode (empty/invalid key); strategy flags ignored; always integers_to_arrays, mba_binops, encrypt_strings (no virt; 1000 char limit)
42 // result.license_expiration - license end date (Y-m-d), empty if none
43 // result.usages_total - total obfuscations 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(PythonObfuscatorResponse::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 "License expiration - {:?}",
58 obj.license_expiration
59 );
60 println!(
61 "Total obfuscations - {}",
62 obj.usages_total.unwrap_or(0)
63 );
64 println!(
65 "Max. source code size - {}",
66 obj.string_limit.unwrap_or(0)
67 );
68 }
69 Some(PythonObfuscatorResponse::Json(_)) => {}
70 None => {
71 return Err("Something unexpected happen while trying to login to the service.".into());
72 }
73 }
74
75 Ok(())
76}