Skip to content

Instantly share code, notes, and snippets.

@scottleedavis
Created September 7, 2019 19:51
Show Gist options
  • Save scottleedavis/25f5e7d1b97dcb8964b74712cfbc6a29 to your computer and use it in GitHub Desktop.
Save scottleedavis/25f5e7d1b97dcb8964b74712cfbc6a29 to your computer and use it in GitHub Desktop.
package main
import (
"bufio"
"bytes"
"fmt"
"gopkg.in/auyer/steganography.v2"
"image"
"os"
)
func main() {
inFile, err := os.Open("./assets/pre_test.png") // opening file
if err != nil {
fmt.Println("unable to open file")
}
defer inFile.Close()
reader := bufio.NewReader(inFile) // buffer reader
img, _, err := image.Decode(reader)
if err != nil {
fmt.Println("ERROR: original image is corrupt " + err.Error())
return
}
w := &bytes.Buffer{}
err = steganography.Encode(w, img, []byte("this is a watermark"))
if err != nil {
fmt.Println(err.Error())
}
reader = bufio.NewReader(w)
img, _, err = image.Decode(reader)
if err != nil {
fmt.Println(err.Error())
}
sizeOfMessage := steganography.GetMessageSizeFromImage(img)
msg := steganography.Decode(sizeOfMessage, img)
fmt.Println("**** " + string(msg))
}
@scottleedavis
Copy link
Author

it must be the image (for the png issue)... it is working with a new png.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment