stringencrypt 1.0.0

Official Rust client for the StringEncrypt.com Web API — generate polymorphic decryptors for many programming languages.
Documentation
///////////////////////////////////////////////////////////////////////////////
//
// StringEncrypt WebApi interface usage example.
//
// In this example we will encrypt sample file with default options.
//
// Version        : v1.0.0
// Language       : Rust
// Author         : Bartosz Wójcik
// Project page   : https://www.stringencrypt.com
// Web page       : https://www.pelock.com
//
///////////////////////////////////////////////////////////////////////////////

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); // leave empty for demo mode
    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");

    // Full license: raw bytes from file (demo may return ERROR_DEMO).
    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());
}