use std::path::PathBuf;
use stringencrypt::{ErrorCode, Language, NewLine, StringEncrypt};
#[tokio::main]
async fn main() {
let mut string_encrypt = StringEncrypt::new("YOUR-API-KEY-HERE", false); string_encrypt
.set_compression(false)
.set_unicode(true)
.set_lang_locale("en_US.utf8")
.set_new_lines(NewLine::LF)
.set_ansi_encoding("WINDOWS-1250")
.set_language(Language::PHP)
.set_cmd_min(1)
.set_cmd_max(3)
.set_local(false);
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
path.push("examples");
path.push("sample.bin");
let result = string_encrypt
.encrypt_file_contents(&path, "$label")
.await;
let Some(result) = result else {
println!("Cannot connect to the API or file is missing/empty.");
std::process::exit(1);
};
if result.error != Some(ErrorCode::SUCCESS as i64) {
println!("API error: {:?}", result.error);
std::process::exit(1);
}
println!("{}\n", result.source.unwrap_or_default());
}