Created
September 7, 2019 19:51
-
-
Save scottleedavis/25f5e7d1b97dcb8964b74712cfbc6a29 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | |
} |
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
jpg test with decode.go, with above approach has this output currently.