steganography

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(input gqlgen.DecodeImageInput) (string, error)

Decode decodes the data from the given generated.DecodeImageInput input.

func Encode

func Encode(input gqlgen.EncodeImageInput) (string, error)

Encode encodes a message into the given graphql.Upload file based on input. Returns the image data base64 encoded.

func GetNRGBAValues

func GetNRGBAValues(
	imageData util.ImageData,
	pixelOffset int,
	lsbUsed byte,
	channel util.Channel,
	distributionDivisor int,
	bufferLength int,
) (*bytes.Buffer, error)

GetNRGBAValues returns bytes.Buffer with ChannelType values.

func LSBSlice

func LSBSlice(used byte) []byte

LSBSlice returns a slice with the lsbs based on the used byte.

func NRGBAPixels

func NRGBAPixels(
	data util.ImageData,
	pixelOffset int,
	channel util.Channel,
	distributionDivisor int,
	resultChan chan PixelData,
)

NRGBAPixels sends PixelData of util.ImageData based on given parameters.

func SetNRGBAValues

func SetNRGBAValues(
	imageData util.ImageData,
	encodeData []byte,
	pixelOffset int,
	lsbUsed byte,
	channel util.Channel,
	distributionDivisor int,
)

SetNRGBAValues sets ChannelType values into util.ImageData based on params.

func ValidateDecodeInput

func ValidateDecodeInput(
	ctx context.Context,
	user *ent.User,
	input gqlgen.DecodeImageInput,
) error

ValidateDecodeInput validates the generated.DecodeImageInput.

func ValidateEncodeInput

func ValidateEncodeInput(
	ctx context.Context,
	user *ent.User,
	input gqlgen.EncodeImageInput,
) error

ValidateEncodeInput validates the generated.EncodeImageInput.

func ValidateLSB

func ValidateLSB(n byte) bool

ValidateLSB validates that the number n is within the LSB range.

Types

type ChannelType

type ChannelType byte

ChannelType represents a pixel color channel.

const (
	// RedChannel represents the red ChannelType.
	RedChannel ChannelType = iota
	// GreenChannel represents the red ChannelType.
	GreenChannel
	// BlueChannel represents the red ChannelType.
	BlueChannel
)

func (ChannelType) IsBlue

func (ct ChannelType) IsBlue() bool

IsBlue returns whether the ChannelType represents a BlueChannel.

func (ChannelType) IsGreen

func (ct ChannelType) IsGreen() bool

IsGreen returns whether the ChannelType represents a GreenChannel.

func (ChannelType) IsRed

func (ct ChannelType) IsRed() bool

IsRed returns whether the ChannelType represents a RedChannel.

type Metadata

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

Metadata represents information which was used to encode data into an image.

func MetadataFromBinaryBuffer

func MetadataFromBinaryBuffer(binaryBuffer *bytes.Buffer) (*Metadata, error)

MetadataFromBinaryBuffer creates a new Metadata from bytes.Buffer.

func MetadataFromEncodeInput

func MetadataFromEncodeInput(
	input gqlgen.EncodeImageInput,
	messageLength int,
) Metadata

MetadataFromEncodeInput creates Metadata from generated.EncodeImageInput.

func MetadataFromImageData

func MetadataFromImageData(imageData util.ImageData) (*Metadata, error)

MetadataFromImageData creates a new Metadata from util.ImageData.

func (Metadata) EncodeIntoImageData

func (md Metadata) EncodeIntoImageData(imageData util.ImageData)

EncodeIntoImageData encodes the data represented into util.ImageData.

func (Metadata) GetBinaryLength

func (md Metadata) GetBinaryLength() uint64

GetBinaryLength returns the expected binary length of the data represented.

func (Metadata) GetChannel

func (md Metadata) GetChannel() util.Channel

GetChannel returns the model.Channel represented by the Metadata.

func (Metadata) GetDistributionDivisor

func (md Metadata) GetDistributionDivisor(imageData util.ImageData) int

GetDistributionDivisor calculates the distribution divisor represented.

func (Metadata) PixelsNeeded

func (md Metadata) PixelsNeeded() uint64

PixelsNeeded returns needed pixels for encoding data based on its Metadata.

func (Metadata) ToByteArr

func (md Metadata) ToByteArr() []byte

ToByteArr turns the Metadata into an array of bytes.

type PixelData

type PixelData struct {
	Width    int
	Height   int
	Channels []ChannelType
	Color    *color.NRGBA
}

PixelData represents data of one particular pixel of an image.

func (PixelData) GetBlue

func (pd PixelData) GetBlue() byte

GetBlue returns the underlying value of the BlueChannel of the PixelData.

func (PixelData) GetChannelValue

func (pd PixelData) GetChannelValue(channel ChannelType) byte

GetChannelValue returns the value of the ChannelType of the PixelData.

func (PixelData) GetGreen

func (pd PixelData) GetGreen() byte

GetGreen returns the underlying value of the GreenChannel of the PixelData.

func (PixelData) GetRed

func (pd PixelData) GetRed() byte

GetRed returns the underlying value of the RedChannel of the PixelData.

func (*PixelData) SetBlue

func (pd *PixelData) SetBlue(value byte)

SetBlue sets the BlueChannel of the PixelData.

func (PixelData) SetChannelValue

func (pd PixelData) SetChannelValue(
	channel ChannelType,
	value byte,
	lsbPos byte,
)

SetChannelValue sets the value of ChannelType of the PixelData on lsbPos.

func (*PixelData) SetGreen

func (pd *PixelData) SetGreen(value byte)

SetGreen sets the GreenChannel of the PixelData.

func (*PixelData) SetRed

func (pd *PixelData) SetRed(value byte)

SetRed sets the RedChannel of the PixelData.

Jump to

Keyboard shortcuts

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