Skip to content

lochrist/UniSteg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Unitils

Library containing multiple Unity utilities function and workflows.

Steganography

This utility namespace implements a simple steganography algorithm allowing a user to "hide" data inside a Unity Texture2D. Basically it uses the least significant bits of the color channels to hier data.

A quick example can be found in SteganoCtrl.cs (used in the Steganography scene):

void Start () {
    sr = gameObject.GetComponent<SpriteRenderer>();

    // Encode secretMsg in a texture. This returns a copy of the texture
    encodedTex = Steganography.Encode(sr.sprite.texture, secretMsg);

    // Set the new texture in our Sprite component
    sr.sprite = Sprite.Create(encodedTex, new Rect(0.0f, 0.0f, encodedTex.width, encodedTex.height), new Vector2(0.5f, 0.5f));
}

private void OnGUI()
{
    GUILayout.BeginHorizontal();

    isDecoded = GUILayout.Toggle(isDecoded, "Decode");
    if (isDecoded)
    {
        // Decode the secretMsg from the texture
        var decodedMsg = Steganography.DecodeAsString(sr.sprite.texture);
        GUILayout.Label(decodedMsg);
    }
    else
    {
        GUILayout.Label("**********************");
    }

    GUILayout.Button(encodedTex);
    GUILayout.EndHorizontal();
}

More details

We support multiple ways to encode data depending on how you want to store the data and affect image quality:

public enum Format
{
    RGB1,
    RGB2,
    RGBA1,
    RGBA2,
    A1,
    A2
}

Each stream of data has a 8 bytes header that contains the format the data is written with and the size of the written data.

About

Unity utilities and a Steganography library

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages