png

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 29, 2021 License: BSD-3-Clause Imports: 11 Imported by: 0

README

stegano/png

An image steganography implementation that outputs PNG steganograms. It accepts both JPEG and PNG images as input.

It satisfies the interface defined by github.com/zanicar/stegano A command line implementation is available here.

Package Documentation

https://pkg.go.dev/github.com/zanicar/stegano/png

How this package works

PNG images use lossless compression, thus data can be written to individual pixels without risk of being destroyed by the compression algorithm. For a JPEG implementation the data will have to be concealed within the compression algorithm's output matrices to prevent dataloss. This implementation also deliberately ignores the alpha channel for pixels, as alpha channels typically do not contain sufficient noise for concealment purposes.

The Conceal method conceals the given data in the pixels of the image decoded from reader and writes the result to writer as a new PNG image.

The Reveal method extracts data from the pixels of the image decoded from reader and writes the result to writer as a binary file.

Refer to the documentation given above for package usage.

Examples

This tiny version of my profile image contains the link to this repository.

steganogram

More examples here

Documentation

Overview

Package png provides a steganography implementation that outputs PNG image steganograms. It accepts both JPEG and PNG images as input.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateCapacity

func CalculateCapacity(width, height, channels, bitsPerByte int) int

CalculateCapacity determines the maximum number of bytes that can be concealed within the image of the given parameters.

Types

type SteganoPNG

type SteganoPNG struct {
	// contains filtered or unexported fields
}

SteganoPNG implements the Stegano interface for PNG image steganograms.

func New

func New() *SteganoPNG

New returns a pointer to a new instance of SteganoPNG that is ready to use.

func (SteganoPNG) Conceal

func (s SteganoPNG) Conceal(data []byte, r io.Reader, w io.Writer) error

Conceal encodes the given data to the two least significant bits of the RGB channels of the image decoded from reader and writes a new PNG image to the writer. The alpha channel is deliberately ommitted as alpha channels rarely provide sufficient noise for proper concealment. The given data is also spread across the available encoding bytes. The function returns an error on failure.

func (SteganoPNG) Reveal

func (s SteganoPNG) Reveal(r io.Reader, w io.Writer) error

Reveal uncovers any steganographic data from the PNG image decoded from reader and writes the output to the writer. It first decodes a mapped byte from the first available encoding byte to determine the length of the subsequent bytes holding the content length. The content length is decoded from the subsequent bytes whereafter the content is decoded from the entire data space. The function returns an error on failure.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL