Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Cmd = &cli.Cmd[hideArgs]{ Name: "hide", Usage: "hide [INPUT IMAGE PATH] [DATA FILE PATH] [OUTPUT IMAGE PATH]", Description: "hide data inside an image using steganography", Examples: []cli.Example{ { Description: "hide data from 'secret.dat' in the in 'img.png'", Args: []string{"src.jpeg", "secret.dat", "img.png"}, }, { Description: "only png files are supported as output files", Args: []string{"src.jpeg", "secret.dat", "img.jpeg"}, Error: errors.New("png is the only supported output image format"), }, }, ParseArgs: func(args []string) (hideArgs, error) { if len(args) != 3 { return hideArgs{}, errors.New("expected exactly 3 arguments") } if !strings.HasSuffix(args[2], ".png") { return hideArgs{}, errors.New("png is the only supported output image format") } return hideArgs{ inputPath: args[0], dataPath: args[1], outputPath: args[2], }, nil }, Fn: func(args hideArgs) error { imageFile, err := os.Open(args.inputPath) if err != nil { return fmt.Errorf("failed to read image file: %w", err) } defer imageFile.Close() img, _, err := image.Decode(imageFile) if err != nil { return fmt.Errorf("failed to decode png file: %w", err) } rawData, err := os.ReadFile(args.dataPath) if err != nil { return fmt.Errorf("failed to read in data to encode: %w", err) } rgbaImg := image.NewNRGBA(img.Bounds()) draw.Draw(rgbaImg, img.Bounds(), img, image.Pt(0, 0), draw.Src) hideData(rawData, rgbaImg) fout, err := os.Create(args.outputPath) if err != nil { return fmt.Errorf("failed to open destination file: %w", err) } defer fout.Close() err = png.Encode(fout, rgbaImg) if err != nil { return fmt.Errorf("failed to encode png output image: %w", err) } return nil }, }
Cmd is the hide command that hides data in the least significant bit of the given image. it will then write a new 'png' image to the output file path with that hidden data.
View Source
var MagicNumber uint16 = 0x1337
MagicNumber is the magic number that indicates that there is data hidden in this image
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.