Documentation
¶
Index ¶
- Constants
- Variables
- func Decodeimage(path string) (image.Image, error)
- func DecryptData(ciphertext []byte, password string) (plaintext []byte, err error)
- func EmbedFile(coverImagePath, dataFilePath, outputFilePath, password string, bitDepth uint8) error
- func EncryptData(data []byte, password string) (ciphertext []byte, err error)
- func ExtractFile(coverImagePath, password string, bitDepth uint8) error
- func GetImageCapacity(coverImage image.Image, bitDepth uint8) int
- func LoadAudioData(file string) *wav.Decoder
- func RsDecode(packedDataShards []byte, parity int) ([]byte, error)
- func RsEncode(data []byte, parity int) ([]byte, error)
- func SaveAudioToFile(fileName string, decoder *wav.Decoder, buffer *audio.IntBuffer) error
- func SaveImage(outputfile string, embeddedImage image.Image) error
- type AudioEmbedHandler
- type AudioExtractHandler
- type EmbedHandler
- func (m *EmbedHandler) EmbedAtDepth(coverimage image.Image, data []byte, depth uint8) (image.Image, error)
- func (m *EmbedHandler) EmbedDataIntoImage(coverImage image.Image, data []byte, bitDepth uint8) (image.Image, error)
- func (m *EmbedHandler) Encode(coverImage image.Image, data []byte, bitDepth uint8, outputFilename string, ...) error
- type ExtractHandler
- func (m *ExtractHandler) Decode(coverImage image.Image, bitDepth uint8, isDefaultCompressed bool) ([]byte, error)
- func (m *ExtractHandler) ExtractAtDepth(coverimage image.Image, depth uint8) ([]byte, error)
- func (m *ExtractHandler) ExtractDataFromImage(coverImage image.Image, bitDepth uint8) ([]byte, error)
- type SecureEmbedHandler
- type SecureExtractHandler
Constants ¶
const ( LSB uint8 = 0 MaxBitDepth uint8 = 7 )
Variables ¶
var ( ErrDepthOutOfRange = errors.New("bitDepth is out of range (0-7)") ErrFailedToExtractRGB = errors.New("failed to extract RGB channels from the image") ErrFailedToExtractData = errors.New("failed to extract data from RGB channels") ErrInvalidDataLength = errors.New("extracted data length is zero") ErrInvalidCoverImage = errors.New("coverImage is nil or has invalid dimensions") ErrInvalidData = errors.New("data is empty or invalid") ErrDataTooLarge = errors.New("data exceeds the embedding capacity of the image") ErrFailedToCompressData = errors.New("failed to compress data") ErrFailedToDecryptData = errors.New("failed to decrypt data") ErrFailedToSaveImage = errors.New("failed to save image") )
Errors for image_embedder.go and image_core.go
var (
DefaultOutputFile string = "stegano_out.png"
)
var (
ErrInvalidGoroutines = errors.New("invalid number of goroutines")
)
Errors for methods.go
Functions ¶
func Decodeimage ¶ added in v1.4.3
takes in path to image and returns image.Image
func DecryptData ¶ added in v1.5.0
DecryptData decrypts the given ciphertext using the provided password. It returns the decrypted plaintext or an error if the decryption fails.
Parameters: - ciphertext ([]byte): The encrypted data to be decrypted. - password (string): The password to be used for decryption.
Returns: - plaintext ([]byte): The decrypted data. - err (error): An error if the decryption fails.
func EmbedFile ¶ added in v1.5.0
ExtractFile extracts embedded data from an image using a default bit depth of 1 (the last two bits in a byte). The embedded data is decrypted and decompressed using the provided password. The extracted file is saved using its original name (stored within the embedded data). Returns an error if the process fails at any stage.
Parameters: - coverImagePath: The file path of the image containing embedded data. - password: A password used to decrypt the embedded data after extraction.
func EncryptData ¶ added in v1.5.0
EncryptData encrypts the given data using the provided password. It returns the encrypted ciphertext or an error if the encryption fails.
Parameters: - data ([]byte): The plaintext data to be encrypted. - password (string): The password to be used for encryption.
Returns: - ciphertext ([]byte): The encrypted data. - err (error): An error if the encryption fails.
func ExtractFile ¶ added in v1.5.0
ExtractFile extracts embedded data from an image using a default bit depth of 1 (the last two bits in a byte). The embedded data is decrypted and decompressed using the provided password. The extracted file is saved using its original name (stored within the embedded data). Returns an error if the process fails at any stage.
Parameters: - coverImagePath: The file path of the image containing embedded data. - password: A password used to decrypt the embedded data after extraction.
func GetImageCapacity ¶ added in v1.4.1
GetImageCapacity calculates the maximum amount of data (in bytes) that can be embedded in the given image, based on the specified bit depth. Returns 0 if the bit depth exceeds 7, as higher depths are unsupported.
func LoadAudioData ¶ added in v1.7.4
GetAudioData opens the WAV file and returns a decoder
func SaveAudioToFile ¶ added in v1.7.4
WriteAudioFile writes the decoded and modified data to a new WAV file
func SaveImage ¶ added in v1.4.6
SaveImage saves the provided image to the specified output file.
Parameters:
outputfile: The path to the output PNG file. Must not be empty and must have a .png extension. embeddedImage: The image to save. Must not be nil.
Returns:
An error if the input is invalid or if an issue occurs during the file creation or encoding process.
Types ¶
type AudioEmbedHandler ¶ added in v1.7.0
type AudioEmbedHandler struct{}
func NewAudioEmbedHandler ¶ added in v1.7.2
func NewAudioEmbedHandler() *AudioEmbedHandler
func (*AudioEmbedHandler) EmbedIntoWAVAtDepth ¶ added in v1.7.4
func (s *AudioEmbedHandler) EmbedIntoWAVAtDepth(audioFilename, outputFilename string, data []byte, bitDepth uint8) error
EmbedDataIntoWAVAtDepth embeds compressed data into a WAV file at a specified bit depth.
func (*AudioEmbedHandler) EmbedIntoWAVWithDepth ¶ added in v1.7.4
func (s *AudioEmbedHandler) EmbedIntoWAVWithDepth(audioFilename, outputFilename string, data []byte, bitDepth uint8) error
EmbedDataIntoWAVWithDepth embeds compressed data into a WAV file with a specified bit depth.
type AudioExtractHandler ¶ added in v1.7.0
type AudioExtractHandler struct{}
func NewAudioExtractHandler ¶ added in v1.7.0
func NewAudioExtractHandler() *AudioExtractHandler
func (*AudioExtractHandler) ExtractFromWAVAtDepth ¶ added in v1.7.4
func (s *AudioExtractHandler) ExtractFromWAVAtDepth(audioFilename string, bitDepth uint8) ([]byte, error)
ExtractDataFromWAVAtDepth extracts compressed data from a WAV file at a specified bit depth.
func (*AudioExtractHandler) ExtractFromWAVWithDepth ¶ added in v1.7.4
func (s *AudioExtractHandler) ExtractFromWAVWithDepth(audioFilename string, bitDepth uint8) ([]byte, error)
ExtractDataFromWAVWithDepth extracts compressed data from a WAV file with a specified bit depth.
type EmbedHandler ¶ added in v1.4.1
type EmbedHandler struct {
// contains filtered or unexported fields
}
func NewEmbedHandler ¶ added in v1.4.1
func NewEmbedHandler() *EmbedHandler
NewEmbedHandler initializes an EmbedHandler with default concurrency
func NewEmbedHandlerWithConcurrency ¶ added in v1.4.4
func NewEmbedHandlerWithConcurrency(concurrency int) (*EmbedHandler, error)
NewEmbedHandlerWithConcurrency initializes an EmbedHandler with a specified concurrency
func (*EmbedHandler) EmbedAtDepth ¶ added in v1.4.1
func (m *EmbedHandler) EmbedAtDepth(coverimage image.Image, data []byte, depth uint8) (image.Image, error)
EmbedAtDepth embeds the provided data into a specific bit depth of the RGB channels of the image. Unlike other embedding methods, this modifies a single bit per channel at the specified depth.
func (*EmbedHandler) EmbedDataIntoImage ¶ added in v1.4.1
func (m *EmbedHandler) EmbedDataIntoImage(coverImage image.Image, data []byte, bitDepth uint8) (image.Image, error)
EmbedDataIntoImage embeds the given data into the RGB channels of the specified image.
func (*EmbedHandler) Encode ¶ added in v1.5.31
func (m *EmbedHandler) Encode(coverImage image.Image, data []byte, bitDepth uint8, outputFilename string, defaultCompression bool) error
Parameters: - coverImage: The original image where data will be embedded. - data: The data to embed into the image. - bitDepth: The number of bits per channel used for embedding (0-7). - outputFilename: The name of the file where the modified image will be saved. - defaultCompression: A flag indicating whether the data should be compressed before embedding.
type ExtractHandler ¶ added in v1.4.1
type ExtractHandler struct {
// contains filtered or unexported fields
}
func NewExtractHandler ¶ added in v1.4.1
func NewExtractHandler() *ExtractHandler
NewExtractHandler initializes an ExtractHandler with default concurrency
func NewExtractHandlerWithConcurrency ¶ added in v1.4.4
func NewExtractHandlerWithConcurrency(concurrency int) (*ExtractHandler, error)
NewExtractHandlerWithConcurrency initializes an ExtractHandler with a specified concurrency
func (*ExtractHandler) Decode ¶ added in v1.4.1
func (m *ExtractHandler) Decode(coverImage image.Image, bitDepth uint8, isDefaultCompressed bool) ([]byte, error)
Decode extracts data embedded in an image using the specified bit depth. If the embedded data was compressed, it will be decompressed when `isDefaultCompressed` is true. Returns the extracted data or an error if the extraction or decompression fails.
Parameters: - coverImage: The image containing embedded data to be extracted. - bitDepth: The bit depth used during the embedding process. - isDefaultCompressed: A flag indicating whether the embedded data was compressed.
func (*ExtractHandler) ExtractAtDepth ¶ added in v1.4.1
ExtractAtDepth extracts data embedded at a specific bit depth from the RGB channels of an image. Only retrieves data from the specified bit depth. Returns the extracted data or an error if the process fails.
func (*ExtractHandler) ExtractDataFromImage ¶ added in v1.4.1
func (m *ExtractHandler) ExtractDataFromImage(coverImage image.Image, bitDepth uint8) ([]byte, error)
ExtractDataFromImage retrieves data embedded in the RGB channels of the specified image.
type SecureEmbedHandler ¶ added in v1.5.31
type SecureEmbedHandler struct {
// contains filtered or unexported fields
}
func NewSecureEmbedHandler ¶ added in v1.5.2
func NewSecureEmbedHandler() *SecureEmbedHandler
NewSecureEmbedHandler initializes a SecureEmbedHandler with default concurrency
func NewSecureEmbedHandlerWithConcurrency ¶ added in v1.5.2
func NewSecureEmbedHandlerWithConcurrency(concurrency int) (*SecureEmbedHandler, error)
NewSecureEmbedHandlerWithConcurrency initializes a SecureEmbedHandler with a specified concurrency
func (*SecureEmbedHandler) Encode ¶ added in v1.5.31
func (m *SecureEmbedHandler) Encode(coverImage image.Image, data []byte, bitDepth uint8, outputFilename string, password string) error
Encode embeds data into a cover image using a specified bit depth, encrypts and compresses the data, and saves the resulting image to the specified output file. Secure uses reed solomon codes for persistency Parameters: - coverImage: The image to embed data into. - data: The data to embed in the image. - bitDepth: The bit depth used for embedding (valid range: 0-7). - outputFilename: The file name to save the resulting image. Defaults to a pre-defined name if empty. - password: The password used to encrypt the data. Returns: - error: An error if any part of the embedding process fails.
type SecureExtractHandler ¶ added in v1.5.31
type SecureExtractHandler struct {
// contains filtered or unexported fields
}
func NewSecureExtractHandler ¶ added in v1.5.2
func NewSecureExtractHandler() *SecureExtractHandler
NewSecureExtractHandler initializes a SecureExtractHandler with default concurrency
func NewSecureExtractHandlerWithConcurrency ¶ added in v1.5.2
func NewSecureExtractHandlerWithConcurrency(concurrency int) (*SecureExtractHandler, error)
NewSecureExtractHandlerWithConcurrency initializes a SecureExtractHandler with a specified concurrency
func (*SecureExtractHandler) Decode ¶ added in v1.5.31
func (m *SecureExtractHandler) Decode(coverImage image.Image, bitDepth uint8, password string) ([]byte, error)
Decode extracts embedded data from a cover image using a specified bit depth, decrypts and decompresses it, and returns the original data. Secure uses reed solomon codes for persistency Parameters: - coverImage: The image containing the embedded data. - bitDepth: The bit depth used for extracting data (valid range: 0-7). - password: The password used to decrypt the embedded data. Returns: - []byte: The extracted original data. - error: An error if the extraction process fails.