Steganografia Kodek Online Dokumentacja Web API SDK

Zautomatyzuj ukrywanie sekretnych danych w obrazkach i zdjęciach z użyciem pakietów Web API SDK Steganografia Kodek Online (Python, JavaScript, Rust, C# / .NET, NuGet).

Opis

Możesz skorzystać ze wszystkich funkcji Steganografia Kodek Online poprzez nasz interfejs Web API. Interfejs Web API bazuje na zapytaniu POST i zwraca wynik zakodowany jako JSON.

Instalacja

Dla szybszego wdrożenia możesz zainstalować pakiety SDK poprzez popularne repozytoria bibliotek (PyPI, npm, crates.io, NuGet). Kody źródłowe są także dostępne na GitHubie:

Repozytorium Język Instalacja Pakiet Źródła
Repozytorium PyPI dla Pythona Python pip install steganography-online-codec PyPI GitHub
Język programowania JavaScript JavaScript

Run

npm i steganography-online-codec

lub dodaj do sekcji dependencies w pliku konfiguracyjnym package.json wpis:

"dependencies": {
"steganography-online-codec": "latest"
},

npm GitHub
Repozytorium Crates.io dla Rust Rust

Uruchom:

cargo add steganography-online-codec

lub dodaj w pliku Cargo.toml w sekcji [dependencies] wpis:

steganography-online-codec = "1"
Crates GitHub
Repozytorium NuGet C#

Uruchom:

dotnet add package SteganographyOnlineCodec

lub dodaj w pliku .csproj:

<PackageReference
Include="SteganographyOnlineCodec"
Version="1.0.1" />
NuGet GitHub

Przykłady użycia

Ukrywanie zaszyfrowanej wiadomości w pliku obrazka

#!/usr/bin/env python

###############################################################################
#
# Steganography Online Codec WebApi interface usage example.
#
# This example shows how to hide an encrypted secret message in an image file.
#
# Version      : v1.00
# Language     : Python
# Author       : Bartosz Wójcik
# Project      : https://www.pelock.com/products/steganography-online-codec
# Homepage     : https://www.pelock.com
#
###############################################################################

#
# include Steganography Online Codec module
#
from steganography_online_codec import *

#
# create Steganography Online Codec class instance (we are using our activation key)
#
mySteganographyOnlineCodec = SteganographyOnlineCodec("YOUR-WEB-API-KEY")

#
# encode a hidden message (encrypted with your password) within an image file
#
result = mySteganographyOnlineCodec.encode("input_file.jpg", "Secret message", "Pa$$word", "output_file_with_hidden_secret_message.png")

#
# result[] array holds the encoding results as well as other information
#
if result and "error" in result:
    if result["error"] == Errors.SUCCESS:
        print(f'Secret message encoded and saved to the output PNG file.')
    else:
        print(f'Error code {result["error"]}')
else:
    print("Something unexpected happen while trying to encode the message.")
"use strict";

/******************************************************************************
 *
 * Steganography Online Codec WebApi interface usage example.
 *
 * In this example shows how to hide an encrypted secret message in an image file.
 *
 * Version      : v1.00
 * Language     : JavaScript
 * Author       : Bartosz Wójcik (original example)
 * Project      : https://www.pelock.com/products/steganography-online-codec
 * Homepage     : https://www.pelock.com
 *
 * @link https://www.pelock.com/products/steganography-online-codec
 * @copyright Copyright (c) 2020-2025 PELock LLC
 * @license Apache-2.0
 *
/*****************************************************************************/

// include Steganography Online Codec module
import { SteganographyOnlineCodec, Errors } from 'steganography-online-codec';
// or if tested locally use:
//import { SteganographyOnlineCodec, Errors } from '../src/SteganographyOnlineCodec.mjs';

// create Steganography Online Codec class instance (we are using our activation key)
const mySteganographyOnlineCodec = new SteganographyOnlineCodec('YOUR-WEB-API-KEY');

// encode a hidden message (encrypted with your password) within an image file
(async () => {

	const inputFile = 'input_file.jpg';
	const secretMessage = 'Secret message';
	const password = 'Pa$$word';
	const outputFile = 'output_file_with_hidden_secret_message.png';

	try {
		const result = await mySteganographyOnlineCodec.encode(inputFile, secretMessage, password, outputFile);

		// result object holds the encoding results as well as other information
		console.log('Secret message encoded and saved to the output PNG file.');
	} catch (err) {
		console.error('Encoding failed:', err.error_message || err.message || String(err));
	}
})();
// Example: hide an encrypted secret message in an image via the Web API.

use steganography_online_codec::SteganographyOnlineCodec;

#[tokio::main]
async fn main() {
    let my_steganography_online_codec =
        SteganographyOnlineCodec::new(Some("YOUR-WEB-API-KEY".to_string()));

    let input_file = "input_file.jpg";
    let secret_message = "Secret message";
    let password = "Pa$$word";
    let output_file = "output_file_with_hidden_secret_message.png";

    match my_steganography_online_codec
        .encode(input_file, secret_message, password, output_file)
        .await
    {
        Ok(_result) => {
            println!("Secret messaged encoded and saved to the output PNG file.");
        }
        Err(err) => {
            eprintln!("Encoding failed: {}", err.error_message());
        }
    }
}
/******************************************************************************
 *
 * Steganography Online Codec WebApi interface usage example.
 *
 * In this example shows how to hide an encrypted secret message in an image file.
 *
 * Version      : v1.00
 * Language     : C#
 * Author       : Bartosz Wójcik (original example)
 * Project      : https://www.pelock.com/products/steganography-online-codec
 * Homepage     : https://www.pelock.com
 *
 * @copyright Copyright (c) 2020-2026 PELock LLC
 * @license Apache-2.0
 *
 ******************************************************************************/

using PELock;
// NuGet PackageReference Include="SteganographyOnlineCodec"
// or locally: dotnet add reference ..\src\SteganographyOnlineCodec\SteganographyOnlineCodec.csproj

// create Steganography Online Codec class instance (activation key placeholder)
using var codec = new SteganographyOnlineCodec("YOUR-WEB-API-KEY");

// encode a hidden message (encrypted with your password) within an image file
const string InputFile = "input_file.jpg";
const string SecretMessage = "Secret message";
const string Password = "Pa$$word";
const string OutputFile = "output_file_with_hidden_secret_message.png";

try
{
	await codec.EncodeAsync(InputFile, SecretMessage, Password, OutputFile).ConfigureAwait(false);

	// EncodeResult exposes license telemetry when available.
	Console.WriteLine("Secret messaged encoded and saved to the output PNG file.");
}
catch (SteganographyApiException err)
{
	Console.Error.WriteLine("Encoding failed: " + (!string.IsNullOrEmpty(err.Message)
		? err.Message
		: $"Error code {err.Error}"));
}

Wydobycie ukrytej, sekretnej wiadomości z zakodowanego obrazka

#!/usr/bin/env python

###############################################################################
#
# Steganography Online Codec WebApi interface usage example.
#
# In this example, we will see how to extract a previously encrypted & hidden
# secret message from an image file.
#
# Version      : v1.00
# Language     : Python
# Author       : Bartosz Wójcik
# Project      : https://www.pelock.com/products/steganography-online-codec
# Homepage     : https://www.pelock.com
#
###############################################################################

#
# include Steganography Online Codec module
#
from steganography_online_codec import *

#
# if you don't want to use Python module, you can import directly from the file
#
#from pelock.steganography_online_codec import *


#
# create Steganography Online Codec class instance (we are using our activation key)
#
mySteganographyOnlineCodec = SteganographyOnlineCodec("YOUR-WEB-API-KEY")

#
# extract a hidden message from the previously encoded image file
#

# full version image size limit is set to 10 MB (demo 50 kB max)
# supported image format is PNG and only PNG!
input_file_path = "output_file_with_hidden_secret_message.png"

# full version password length is 128 characters max (demo 8 chars max)
password = "Pa$$word"

# extract a hidden message from the image (PNG files only)
result = mySteganographyOnlineCodec.decode(input_file_path, password)

#
# result[] Dict holds the decoding results as well as other information
#
if result and "error" in result:

    print(f'You are running in {"full" if result["license"]["activationStatus"] is True else "demo"} version')

    if result["error"] == Errors.SUCCESS:
        print(f'Secret message is "{result["message"]}"')
        print(f'Remaining number of usage credits - {result["license"]["usagesCount"]}')
    elif result["error"] == Errors.INVALID_INPUT:
        print(f'Invalid input file {input_file_path} or file doesn''t exist')
    elif result["error"] == Errors.IMAGE_TOO_BIG:
        print(f'Image file is too big, current limit is set to {mySteganographyOnlineCodec.convert_size(result["limits"]["maxFileSize"])}')
    elif result["error"] == Errors.LIMIT_MESSAGE:
        print(f'Extracted message is too long, current limit is set to {result["limits"]["maxMessageLen"]}')
    elif result["error"] == Errors.LIMIT_PASSWORD:
        print(f'Password is too long, current limit is set to {result["limits"]["maxPasswordLen"]}')
    elif result["error"] == Errors.INVALID_PASSWORD:
        print(f'Invalid password')
    else:
        print(f'An unknown error occurred, error code: {result["error"]}')
else:
    print("Something unexpected happen while trying to extract the secret message.")
"use strict";

/******************************************************************************
 *
 * Steganography Online Codec WebApi interface usage example.
 *
 * In this example, we will see how to extract a previously encrypted & hidden
 * secret message from an image file.
 *
 * Version      : v1.00
 * Language     : JavaScript
 * Author       : Bartosz Wójcik
 * Project      : https://www.pelock.com/products/steganography-online-codec
 * Homepage     : https://www.pelock.com
 *
 * @link https://www.pelock.com/products/steganography-online-codec
 * @copyright Copyright (c) 2020-2025 PELock LLC
 * @license Apache-2.0
 *
 /*****************************************************************************/

// include Steganography Online Codec module
import { SteganographyOnlineCodec, Errors } from 'steganography-online-codec';
// or if tested locally use:
//import { SteganographyOnlineCodec, Errors } from '../src/SteganographyOnlineCodec.mjs';

// create Steganography Online Codec class instance (we are using our activation key)
const mySteganographyOnlineCodec = new SteganographyOnlineCodec('YOUR-WEB-API-KEY');

// extract a hidden message from the previously encoded image file
(async () => {
	// full version image size limit is set to 10 MB (demo 50 kB max)
	// supported image format is PNG and only PNG!
	const inputFilePath = 'output_file_with_hidden_secret_message.png';

	// full version password length is 128 characters max (demo 8 chars max)
	const password = 'Pa$$word';

	try {
		// extract a hidden message from the image (PNG files only)
		const result = await mySteganographyOnlineCodec.decode(inputFilePath, password);

		// result object holds the decoding results as well as other information
		console.log(`You are running in ${result.license?.activationStatus ? 'full' : 'demo'} version`);

		console.log(`Secret message is "${result.message}"`);

		if (result.license && result.license.usagesCount !== undefined) {
			console.log(`Remaining number of usage credits - ${result.license.usagesCount}`);
		}
	} catch (err) {
		switch (err.error) {
			case Errors.INVALID_INPUT:
				console.log(`Invalid input file ${inputFilePath} or file doesn't exist`);
				break;
			case Errors.IMAGE_TOO_BIG:
				console.log(`Image file is too big, current limit is set to ${err.raw?.limits?.maxFileSize ?? 'unknown'}`);
				break;
			case Errors.LIMIT_MESSAGE:
				console.log(`Extracted message is too long, current limit is set to ${err.raw?.limits?.maxMessageLen ?? 'unknown'}`);
				break;
			case Errors.LIMIT_PASSWORD:
				console.log(`Password is too long, current limit is set to ${err.raw?.limits?.maxPasswordLen ?? 'unknown'}`);
				break;
			case Errors.INVALID_PASSWORD:
				console.log('Invalid password');
				break;
			default:
				console.log(`An error occurred: ${err.error_message ?? String(err)}`);
		}
	}
})();
// Example: decode (extract) a hidden message from a PNG.

use steganography_online_codec::{errors, SteganographyOnlineCodec};

#[tokio::main]
async fn main() {
    let my_steganography_online_codec =
        SteganographyOnlineCodec::new(Some("YOUR-WEB-API-KEY".to_string()));

    // full version image size limit is set to 10 MB (demo 50 kB max)
    // supported image format is PNG and only PNG!
    let input_file_path = "output_file_with_hidden_secret_message.png";

    // full version password length is 128 characters max (demo 8 chars max)
    let password = "Pa$$word";

    match my_steganography_online_codec
        .decode(input_file_path, password)
        .await
    {
        Ok(result) => {
            let full = result
                .license
                .as_ref()
                .and_then(|l| l.activation_status)
                .unwrap_or(false);
            println!(
                "You are running in {} version",
                if full { "full" } else { "demo" }
            );

            let msg = result.message.as_deref().unwrap_or("");
            println!("Secret message is \"{msg}\"");

            if let Some(ref lic) = result.license {
                if let Some(c) = lic.usages_count {
                    println!("Remaining number of usage credits - {c}");
                }
            }
        }
        Err(err) => match err.code() {
            errors::INVALID_INPUT => {
                println!(
                    "Invalid input file {} or file doesn't exist",
                    input_file_path
                );
            }
            errors::IMAGE_TOO_BIG => {
                let lim = err
                    .raw()
                    .and_then(|j| j.get("limits"))
                    .and_then(|l| l.get("maxFileSize"))
                    .map(|v| v.to_string())
                    .unwrap_or_else(|| "unknown".to_string());
                println!("Image file is too big, current limit is set to {lim}");
            }
            errors::LIMIT_MESSAGE => {
                let lim = err
                    .raw()
                    .and_then(|j| j.get("limits"))
                    .and_then(|l| l.get("maxMessageLen"))
                    .map(|v| v.to_string())
                    .unwrap_or_else(|| "unknown".to_string());
                println!(
                    "Extracted message is too long, current limit is set to {lim}"
                );
            }
            errors::LIMIT_PASSWORD => {
                let lim = err
                    .raw()
                    .and_then(|j| j.get("limits"))
                    .and_then(|l| l.get("maxPasswordLen"))
                    .map(|v| v.to_string())
                    .unwrap_or_else(|| "unknown".to_string());
                println!("Password is too long, current limit is set to {lim}");
            }
            errors::INVALID_PASSWORD => {
                println!("Invalid password");
            }
            _ => {
                println!("An error occurred: {}", err.error_message());
            }
        },
    }
}
/******************************************************************************
 *
 * Steganography Online Codec WebApi interface usage example.
 *
 * In this example, we will see how to extract a previously encrypted & hidden
 * secret message from an image file.
 *
 * Version      : v1.00
 * Language     : C#
 * Author       : Bartosz Wójcik
 * Project      : https://www.pelock.com/products/steganography-online-codec
 * Homepage     : https://www.pelock.com
 *
 * @copyright Copyright (c) 2020-2026 PELock LLC
 * @license Apache-2.0
 *
 ******************************************************************************/

using System.Text.Json;
using PELock;

// NuGet PackageReference Include="SteganographyOnlineCodec"
// or locally: dotnet add reference ..\src\SteganographyOnlineCodec\SteganographyOnlineCodec.csproj

// create Steganography Online Codec class instance (activation key placeholder)
using var codec = new SteganographyOnlineCodec("YOUR-WEB-API-KEY");

// extract a hidden message from the previously encoded image file
// full version image size limit is set to 10 MB (demo 50 kB max)
// supported image format is PNG and only PNG!
string inputFilePath = "output_file_with_hidden_secret_message.png";

// full version password length is 128 characters max (demo 8 chars max)
const string Password = "Pa$$word";

try
{
	// extract a hidden message from the image (PNG files only)
	DecodeResult result =
		await codec.DecodeAsync(inputFilePath, Password).ConfigureAwait(false);

	string runningVersion = result.License?.ActivationStatus == true ? "full" : "demo";

	Console.WriteLine($"You are running in {runningVersion} version");

	Console.WriteLine($"Secret message is \"{result.Message}\"");

	if (result.License?.UsagesCount.HasValue ?? false)
		Console.WriteLine($"Remaining number of usage credits - {result.License!.UsagesCount}");
}
catch (SteganographyApiException err)
{
	switch (err.Error)
	{
	case Errors.InvalidInput:
		Console.WriteLine($"Invalid input file {inputFilePath} or file doesn't exist");
		break;
	case Errors.ImageTooBig:
		Console.WriteLine($"Image file is too big, current limit is set to {ReadLimitDecode(err.Raw, "maxFileSize")}");
		break;
	case Errors.LimitMessage:
		Console.WriteLine($"Extracted message is too long, current limit is set to {ReadLimitDecode(err.Raw, "maxMessageLen")}");
		break;
	case Errors.LimitPassword:
		Console.WriteLine($"Password is too long, current limit is set to {ReadLimitDecode(err.Raw, "maxPasswordLen")}");
		break;
	case Errors.InvalidPassword:
		Console.WriteLine("Invalid password");
		break;
	default:
		Console.WriteLine($"An error occurred: {(string.IsNullOrEmpty(err.Message) ? $"API error code {err.Error}" : err.Message)}");
		break;
	}
}

static string ReadLimitDecode(JsonElement? payload, string key)
{
	if (payload.HasValue &&
		payload.Value.TryGetProperty("limits", out JsonElement limits) &&
		limits.TryGetProperty(key, out JsonElement probe) &&
		probe.ValueKind == JsonValueKind.Number &&
		probe.TryGetInt64(out long value))
	{
		return value.ToString();
	}

	return "unknown";
}

Ukrycie sekretnej wiadomości w zdjęciu (rozszerzona obsługa błędów)

#!/usr/bin/env python

###############################################################################
#
# Steganography Online Codec WebApi interface usage example.
#
# In this example, we will see how to hide an encrypted message in an
# image file using our codec.
#
# Version      : v1.00
# Language     : Python
# Author       : Bartosz Wójcik
# Project      : https://www.pelock.com/products/steganography-online-codec
# Homepage     : https://www.pelock.com
#
###############################################################################

#
# include Steganography Online Codec module
#
from steganography_online_codec import *

#
# if you don't want to use Python module, you can import directly from the file
#
#from pelock.steganography_online_codec import *

#
# create Steganography Online Codec class instance (we are using our activation key)
#
mySteganographyOnlineCodec = SteganographyOnlineCodec("YOUR-WEB-API-KEY")

#
# encode a hidden message within the source image file
#

# full version image size limit is set to 10 MB (demo 50 kB max)
# supported image formats are PNG, JPG, GIF, BMP, WBMP, GD2, AVIF, WEBP (mail me for more)
input_file_path = "input_file.webp"

# full version message size is unlimited (demo 16 chars max)
secret_message = "Secret message"

# full version password length is 128 characters max (demo 8 chars max)
password = "Pa$$word"

# where to save encoded image with the secret message
output_file_path = "output_file_with_hidden_secret_message.png"

# encode a hidden message (encrypted with your password) within an image file
result = mySteganographyOnlineCodec.encode(input_file_path, secret_message, password, output_file_path)

#
# result[] array holds the encoding results as well as other information
#
if result and "error" in result:

    print(f'You are running in {"full" if result["license"]["activationStatus"] is True else "demo"} version')

    if result["error"] == Errors.SUCCESS:
        print(f'Secret message encoded and saved to {output_file_path}')
        print(f'Remaining number of usage credits - {result["license"]["usagesCount"]}')
    elif result["error"] == Errors.INVALID_INPUT:
        print(f'Invalid input file {input_file_path} or file doesn''t exist')
    elif result["error"] == Errors.MESSAGE_TOO_LONG:
        print(f'Message is too long for the provided image file, use larger file')
    elif result["error"] == Errors.IMAGE_TOO_BIG:
        print(f'Image file is too big, current limit is set to {mySteganographyOnlineCodec.convert_size(result["limits"]["maxFileSize"])}')
    elif result["error"] == Errors.LIMIT_MESSAGE:
        print(f'Message is too long, current limit is set to {result["limits"]["maxMessageLen"]}')
    elif result["error"] == Errors.LIMIT_PASSWORD:
        print(f'Password is too long, current limit is set to {result["limits"]["maxPasswordLen"]}')
    elif result["error"] == Errors.INVALID_PASSWORD:
        print(f'Invalid password')
    else:
        print(f'An unknown error occurred, error code: {result["error"]}')
else:
    print("Something unexpected happen while trying to encode the message.")
"use strict";

/******************************************************************************
 *
 * Steganography Online Codec WebApi interface usage example.
 *
 * In this example, we will see how to hide an encrypted message in an
 * image file using our codec.
 *
 * Version      : v1.00
 * Language     : JavaScript
 * Author       : Bartosz Wójcik
 * Project      : https://www.pelock.com/products/steganography-online-codec
 * Homepage     : https://www.pelock.com
 *
 * @link https://www.pelock.com/products/steganography-online-codec
 * @copyright Copyright (c) 2020-2025 PELock LLC
 * @license Apache-2.0
 *
 /*****************************************************************************/

// include Steganography Online Codec module
import { SteganographyOnlineCodec, Errors } from 'steganography-online-codec';
// or if tested locally use:
//import { SteganographyOnlineCodec, Errors } from '../src/SteganographyOnlineCodec.mjs';


// create Steganography Online Codec class instance (we are using our activation key)
const mySteganographyOnlineCodec = new SteganographyOnlineCodec('YOUR-WEB-API-KEY');

// encode a hidden message within the source image file
(async () => {
	// full version image size limit is set to 10 MB (demo 50 kB max)
	// supported image formats are PNG, JPG, GIF, BMP, WBMP, GD2, AVIF, WEBP (mail me for more)
	const inputFilePath = 'input_file.webp';

	// full version message size is unlimited (demo 16 chars max)
	const secretMessage = 'Secret message';

	// full version password length is 128 characters max (demo 8 chars max)
	const password = 'Pa$$word';

	// where to save encoded image with the secret message
	const outputFilePath = 'output_file_with_hidden_secret_message.png';

	try {
		// encode a hidden message (encrypted with your password) within an image file
		const result = await mySteganographyOnlineCodec.encode(inputFilePath, secretMessage, password, outputFilePath);

		// result object holds the encoding results as well as other information
		const versionType = result.license && result.license.activationStatus ? 'full' : 'demo';
		console.log(`You are running in ${versionType} version`);

		console.log(`Secret message encoded and saved to ${outputFilePath}`);
		if (result.license && result.license.usagesCount !== undefined) {
			console.log(`Remaining number of usage credits - ${result.license.usagesCount}`);
		}
	} catch (err) {
		const errorCode = err.error;

		switch (errorCode) {
			case Errors.INVALID_INPUT:
				console.log(`Invalid input file ${inputFilePath} or file doesn't exist`);
				break;
			case Errors.MESSAGE_TOO_LONG:
				console.log('Message is too long for the provided image file, use larger file');
				break;
			case Errors.IMAGE_TOO_BIG:
				console.log(`Image file is too big, current limit is set to ${err.raw?.limits?.maxFileSize ?? 'unknown'}`);
				break;
			case Errors.LIMIT_MESSAGE:
				console.log(`Message is too long, current limit is set to ${err.raw?.limits?.maxMessageLen ?? 'unknown'}`);
				break;
			case Errors.LIMIT_PASSWORD:
				console.log(`Password is too long, current limit is set to ${err.raw?.limits?.maxPasswordLen ?? 'unknown'}`);
				break;
			case Errors.INVALID_PASSWORD:
				console.log('Invalid password');
				break;
			default:
				console.log(`An error occurred: ${err.error_message ?? `Error code ${errorCode}`}`);
		}
	}
})();
// Example: encode with error-code handling (demo vs full limits).

use steganography_online_codec::{errors, SteganographyOnlineCodec};

#[tokio::main]
async fn main() {
    let my_steganography_online_codec =
        SteganographyOnlineCodec::new(Some("YOUR-WEB-API-KEY".to_string()));

    // full version image size limit is set to 10 MB (demo 50 kB max)
    // supported image formats are PNG, JPG, GIF, BMP, WBMP, GD2, AVIF, WEBP (mail me for more)
    let input_file_path = "input_file.webp";

    // full version message size is unlimited (demo 16 chars max)
    let secret_message = "Secret message";

    // full version password length is 128 characters max (demo 8 chars max)
    let password = "Pa$$word";

    // where to save encoded image with the secret message
    let output_file_path = "output_file_with_hidden_secret_message.png";

    match my_steganography_online_codec
        .encode(
            input_file_path,
            secret_message,
            password,
            output_file_path,
        )
        .await
    {
        Ok(result) => {
            let version_type = result
                .license
                .as_ref()
                .and_then(|l| l.activation_status)
                .unwrap_or(false);
            println!(
                "You are running in {} version",
                if version_type { "full" } else { "demo" }
            );

            println!(
                "Secret messaged encoded and saved to {}",
                output_file_path
            );
            if let Some(ref lic) = result.license {
                if let Some(c) = lic.usages_count {
                    println!("Remaining number of usage credits - {c}");
                }
            }
        }
        Err(err) => {
            let error_code = err.code();
            match error_code {
                errors::INVALID_INPUT => {
                    println!(
                        "Invalid input file {} or file doesn't exist",
                        input_file_path
                    );
                }
                errors::MESSAGE_TOO_LONG => {
                    println!(
                        "Message is too long for the provided image file, use larger file"
                    );
                }
                errors::IMAGE_TOO_BIG => {
                    let lim = err
                        .raw()
                        .and_then(|j| j.get("limits"))
                        .and_then(|l| l.get("maxFileSize"))
                        .map(|v| v.to_string())
                        .unwrap_or_else(|| "unknown".to_string());
                    println!("Image file is too big, current limit is set to {lim}");
                }
                errors::LIMIT_MESSAGE => {
                    let lim = err
                        .raw()
                        .and_then(|j| j.get("limits"))
                        .and_then(|l| l.get("maxMessageLen"))
                        .map(|v| v.to_string())
                        .unwrap_or_else(|| "unknown".to_string());
                    println!("Message is too long, current limit is set to {lim}");
                }
                errors::LIMIT_PASSWORD => {
                    let lim = err
                        .raw()
                        .and_then(|j| j.get("limits"))
                        .and_then(|l| l.get("maxPasswordLen"))
                        .map(|v| v.to_string())
                        .unwrap_or_else(|| "unknown".to_string());
                    println!("Password is too long, current limit is set to {lim}");
                }
                errors::INVALID_PASSWORD => {
                    println!("Invalid password");
                }
                _ => {
                    println!("An error occurred: {}", err.error_message());
                }
            }
        }
    }
}
/******************************************************************************
 *
 * Steganography Online Codec WebApi interface usage example.
 *
 * In this example, we will see how to hide an encrypted message in an
 * image file using our codec.
 *
 * Version      : v1.00
 * Language     : C#
 * Author       : Bartosz Wójcik
 * Project      : https://www.pelock.com/products/steganography-online-codec
 * Homepage     : https://www.pelock.com
 *
 * @copyright Copyright (c) 2020-2026 PELock LLC
 * @license Apache-2.0
 *
 ******************************************************************************/

using System.Text.Json;
using PELock;

// NuGet PackageReference Include="SteganographyOnlineCodec"
// or locally: dotnet add reference ..\src\SteganographyOnlineCodec\SteganographyOnlineCodec.csproj

// create Steganography Online Codec class instance (activation key placeholder)
using var codec = new SteganographyOnlineCodec("YOUR-WEB-API-KEY");

// encode a hidden message within the source image file
// full version image size limit is set to 10 MB (demo 50 kB max)
// supported image formats are PNG, JPG, GIF, BMP, WBMP, GD2, AVIF, WEBP (mail me for more)
string inputFilePath = "input_file.webp";

// full version message size is unlimited (demo 16 chars max)
const string SecretMessage = "Secret message";

// full version password length is 128 characters max (demo 8 chars max)
const string Password = "Pa$$word";

// where to save encoded image with the secret message
string outputFilePath = "output_file_with_hidden_secret_message.png";

try
{
	// encode a hidden message (encrypted with your password) within an image file
	EncodeResult result =
		await codec.EncodeAsync(inputFilePath, SecretMessage, Password, outputFilePath).ConfigureAwait(false);

	string versionType = result.License?.ActivationStatus == true ? "full" : "demo";
	Console.WriteLine($"You are running in {versionType} version");

	Console.WriteLine($"Secret messaged encoded and saved to {outputFilePath}");

	if (result.License?.UsagesCount.HasValue ?? false)
		Console.WriteLine($"Remaining number of usage credits - {result.License!.UsagesCount}");
}
catch (SteganographyApiException err)
{
	int errorCode = err.Error;

	switch (errorCode)
	{
	case Errors.InvalidInput:
		Console.WriteLine($"Invalid input file {inputFilePath} or file doesn't exist");
		break;
	case Errors.MessageTooLong:
		Console.WriteLine("Message is too long for the provided image file, use larger file");
		break;
	case Errors.ImageTooBig:
		Console.WriteLine($"Image file is too big, current limit is set to {ReadLimitLong(err.Raw, "maxFileSize")}");
		break;
	case Errors.LimitMessage:
		Console.WriteLine($"Message is too long, current limit is set to {ReadLimitLong(err.Raw, "maxMessageLen")}");
		break;
	case Errors.LimitPassword:
		Console.WriteLine($"Password is too long, current limit is set to {ReadLimitLong(err.Raw, "maxPasswordLen")}");
		break;
	case Errors.InvalidPassword:
		Console.WriteLine("Invalid password");
		break;
	default:
		Console.WriteLine($"An error occurred: {(!string.IsNullOrEmpty(err.Message) ? err.Message : $"Error code {errorCode}")}");
		break;
	}
}

static string ReadLimitLong(JsonElement? payload, string key)
{
	if (payload.HasValue &&
		payload.Value.TryGetProperty("limits", out JsonElement limits) &&
		limits.TryGetProperty(key, out JsonElement probe) &&
		probe.ValueKind == JsonValueKind.Number &&
		probe.TryGetInt64(out long value))
	{
		return value.ToString();
	}

	return "unknown";
}

Sprawdzenie danych licencyjnych

#!/usr/bin/env python

###############################################################################
#
# Steganography Online Codec WebApi interface usage example.
#
# In this example we will verify our activation key status.
#
# Version      : v1.00
# Language     : Python
# Author       : Bartosz Wójcik
# Project      : https://www.pelock.com/products/steganography-online-codec
# Homepage     : https://www.pelock.com
#
###############################################################################

#
# include Steganography Online Codec module
#
from steganography_online_codec import *

#
# if you don't want to use Python module, you can import directly from the file
#
#from pelock.steganography_online_codec import *

#
# create Steganography Online Codec class instance (we are using our activation key)
#
mySteganographyOnlineCodec = SteganographyOnlineCodec("YOUR-WEB-API-KEY")

#
# login to the service
#
result = mySteganographyOnlineCodec.login()

#
# result[] Dict holds the information about the license & current limits
#
if result:

    print(f'You are running in {"full" if result["license"]["activationStatus"] is True else "demo"} version')

    # information about the current license
    if result["license"]["activationStatus"] is True:
        print(f'Registered for - {result["license"]["userName"]}')
        print(f'License type - {"personal" if result["license"]["type"] == 0 else "company"}')
        print(f'Total number of purchased usage credits - {result["license"]["usagesTotal"]}')
        print(f'Remaining number of usage credits - {result["license"]["usagesCount"]}')

    # current limits (different for DEMO and FULL versions)
    print(f'Max. password length - {result["limits"]["maxPasswordLen"]}')
    print(f'Max. message length - {"unlimited" if result["limits"]["maxMessageLen"] == -1 else result["limits"]["maxMessageLen"]}')
    print(f'Max. input image file size - {mySteganographyOnlineCodec.convert_size(result["limits"]["maxFileSize"])}')
else:
    print("Something unexpected happen while trying to login to the service.")
"use strict";

/******************************************************************************
 *
 * Steganography Online Codec WebApi interface usage example.
 *
 * In this example we will verify our activation key status.
 *
 * Version      : v1.00
 * Language     : JavaScript
 * Author       : Bartosz Wójcik
 * Project      : https://www.pelock.com/products/steganography-online-codec
 * Homepage     : https://www.pelock.com
 *
 * @link https://www.pelock.com/products/steganography-online-codec
 * @copyright Copyright (c) 2020-2025 PELock LLC
 * @license Apache-2.0
 *
 /*****************************************************************************/

// include Steganography Online Codec module
import { SteganographyOnlineCodec, Errors } from 'steganography-online-codec';
// or if tested locally use:
//import { SteganographyOnlineCodec, Errors } from '../src/SteganographyOnlineCodec.mjs';

// create Steganography Online Codec class instance (we are using our activation key)
const mySteganographyOnlineCodec = new SteganographyOnlineCodec('YOUR-WEB-API-KEY');

// login to the service
(async () => {
	try {
		const result = await mySteganographyOnlineCodec.login();

		// result object holds the information about the license & current limits
		const versionType = result.license && result.license.activationStatus ? 'full' : 'demo';
		console.log(`You are running in ${versionType} version`);

		// information about the current license
		if (result.license && result.license.activationStatus) {
			console.log(`Registered for - ${result.license.userName}`);
			const licenseType = result.license.type === 0 ? 'personal' : 'company';
			console.log(`License type - ${licenseType}`);
			console.log(`Total number of purchased usage credits - ${result.license.usagesTotal}`);
			console.log(`Remaining number of usage credits - ${result.license.usagesCount}`);
		}

		// current limits (different for DEMO and FULL versions)
		if (result.limits) {
			console.log(`Max. password length - ${result.limits.maxPasswordLen}`);
			const msgLen = result.limits.maxMessageLen === -1 ? 'unlimited' : result.limits.maxMessageLen;
			console.log(`Max. message length - ${msgLen}`);
			console.log(`Max. input image file size - ${mySteganographyOnlineCodec.convert_size(result.limits.maxFileSize)}`);
		}
	} catch (err) {
		console.error(`Login failed: ${err.error_message || String(err)}`);
	}
})();
// Example: check license status and current API limits (`login`).

use steganography_online_codec::SteganographyOnlineCodec;

#[tokio::main]
async fn main() {
    let my_steganography_online_codec =
        SteganographyOnlineCodec::new(Some("YOUR-WEB-API-KEY".to_string()));

    match my_steganography_online_codec.login().await {
        Ok(result) => {
            let version_type = result
                .license
                .as_ref()
                .and_then(|l| l.activation_status)
                .unwrap_or(false);
            println!(
                "You are running in {} version",
                if version_type { "full" } else { "demo" }
            );

            if let Some(ref lic) = result.license {
                if lic.activation_status.unwrap_or(false) {
                    if let Some(ref name) = lic.user_name {
                        println!("Registered for - {name}");
                    }
                    let license_type = if lic.license_type == Some(0) {
                        "personal"
                    } else {
                        "company"
                    };
                    println!("License type - {license_type}");
                    if let Some(t) = lic.usages_total {
                        println!("Total number of purchased usage credits - {t}");
                    }
                    if let Some(c) = lic.usages_count {
                        println!("Remaining number of usage credits - {c}");
                    }
                }
            }

            if let Some(ref limits) = result.limits {
                if let Some(m) = limits.max_password_len {
                    println!("Max. password length - {m}");
                }
                if let Some(ml) = limits.max_message_len {
                    let msg_len = if ml == -1 {
                        "unlimited".to_string()
                    } else {
                        ml.to_string()
                    };
                    println!("Max. message length - {msg_len}");
                }
                if let Some(fs) = limits.max_file_size {
                    println!(
                        "Max. input image file size - {}",
                        SteganographyOnlineCodec::convert_size(fs)
                    );
                }
            }
        }
        Err(err) => {
            eprintln!("Login failed: {}", err.error_message());
        }
    }
}
/******************************************************************************
 *
 * Steganography Online Codec WebApi interface usage example.
 *
 * In this example we will verify our activation key status.
 *
 * Version      : v1.00
 * Language     : C#
 * Author       : Bartosz Wójcik
 * Project      : https://www.pelock.com/products/steganography-online-codec
 * Homepage     : https://www.pelock.com
 *
 * @copyright Copyright (c) 2020-2026 PELock LLC
 * @license Apache-2.0
 *
 ******************************************************************************/

using PELock;

// NuGet PackageReference Include="SteganographyOnlineCodec"
// or locally: dotnet add reference ..\src\SteganographyOnlineCodec\SteganographyOnlineCodec.csproj

// create Steganography Online Codec class instance (activation key placeholder)
using var codec = new SteganographyOnlineCodec("YOUR-WEB-API-KEY");

// login to the service
try
{
	LoginResult result =
		await codec.LoginAsync().ConfigureAwait(false);

	string versionType =
		result.License?.ActivationStatus == true ? "full" : "demo";

	Console.WriteLine($"You are running in {versionType} version");

	if (result.License?.ActivationStatus == true)
	{
		Console.WriteLine($"Registered for - {result.License!.UserName}");
		string licenseType = result.License.Type == 0 ? "personal" : "company";
		Console.WriteLine($"License type - {licenseType}");
		Console.WriteLine($"Total number of purchased usage credits - {result.License.UsagesTotal}");
		Console.WriteLine($"Remaining number of usage credits - {result.License.UsagesCount}");
	}

	if (result.Limits != null)
	{
		Console.WriteLine($"Max. password length - {result.Limits.MaxPasswordLen}");
		string msgLen = result.Limits.MaxMessageLen == -1 ? "unlimited" : result.Limits.MaxMessageLen.ToString();
		Console.WriteLine($"Max. message length - {msgLen}");
		Console.WriteLine($"Max. input image file size - {codec.ConvertSize(result.Limits.MaxFileSize)}");
	}
}
catch (SteganographyApiException err)
{
	Console.Error.WriteLine("Login failed: " + (!string.IsNullOrEmpty(err.Message) ? err.Message : $"Error code {err.Error}"));
}

Zwracane wartości

result["error"] [out]
Kod błędu. Jeden z poniższych:
Nazwa Wartość Opis
WEBAPI_CONNECTION -1 Nie można połączyć się z interfejsem Web API (błąd sieci, zwracany jedynie przez bibliotekę SDK).
SUCCESS 0 Wszystko poszło ok.
UNKNOWN 1 Nieznany błąd.
MESSAGE_TOO_LONG 2 Wiadomość jest zbyt długa dla wybranego pliku obrazka (użyj większy plik obrazka).
IMAGE_TOO_BIG 3 Plik obrazka zbyt duży (limit 10 MB dla pełnej wersji, 50 kB dla wersji DEMO).
INVALID_INPUT 4 Plik obrazka jest nieprawidłowy.
INVALID_IMAGE_FORMAT 5 Format pliku obrazka nie jest obsługiwany.
IMAGE_MALFORMED 6 Plik obrazka jest uszkodzony lub nie można go odczytać albo zapisać do niego zakodowanej wiadomości.
INVALID_PASSWORD 7 Podane hasło jest nieprawidłowe (maksymalny rozmiar hasła to 128 znaków dla pełnej wersji i 8 znaków dla wersji DEMO).
LIMIT_MESSAGE 9 Wiadomość jest zbyt długa (nieograniczony rozmiar dla pełnej wersji, 16 znaków dla wersji DEMO).
LIMIT_PASSWORD 10 Podane hasło ma nieprawidłowy rozmiar (rozmiar to maksymalnie 128 znaków dla pełnej wersji, 8 dla wersji DEMO).
OUTPUT_FILE 99 Błąd podczas zapisywania wyjściowego pliku (zwracany jedynie przez bibliotekę SDK).
INVALID_LICENSE 100 Klucz licencji jest nieprawidłowy lub wygasł (brak kredytów użycia).
result["message"] [out, optional]
Zdekodowana sekretna wiadomość.
result["limits"]["maxFileSize"] [out, optional]
Maksymalny dozwolony rozmiar pliku.
result["limits"]["maxMessageLen"] [out, optional]
Maksymalny dozwolony rozmiar sekretnej wiadomości (domyślnie -1 dla nieograniczonego rozmiaru, który pozwoli wpasować się w rozmiar pliku wejściowego).
result["limits"]["maxPasswordLen"] [out, optional]
Maksymalny dozwolony rozmiar hasła.
result["license"]["activationStatus"] [out, optional]
Status aktywacji - true dla pełnej wersji false dla wersji demo.
result["license"]["userName"] [out, optional]
Nazwa zarejestrowanego użytkownika.
result["license"]["type"] [out, optional]
Rodzaj licencji - 0 for Licencji Osobistej, 1 dla Licencji Firmowej.
result["license"]["usagesTotal"] [out, optional]
Całkowita liczba zakupionych kredytów użycia.
result["license"]["usagesCount"] [out]
Pozostała liczba kredytów użycia (zawsze zwracana przy kodowaniu/dekodowaniu, dla wersji demo jest zawsze ustawiona na 1).

Wymagania

Moduł dla Python steganography-online-codec
JavaScript NPM Module steganography-online-codec
Crate Rust steganography-online-codec
Pakiet NuGet (C# / .NET) SteganographyOnlineCodec

Masz pytania?

Jeśli masz jakieś pytania dotyczące pakietów SDK dla Steganografia Kodek Online, masz jakieś uwagi, coś jest niejasne, napisz do mnie, chętnie odpowiem na każde Twoje pytanie.