Skip to content

Commit

Permalink
improvements to examples
Browse files Browse the repository at this point in the history
  • Loading branch information
auyer committed Sep 7, 2019
1 parent 821908f commit 1aa26d8
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Getting Started
package main
import (
"bufio"
"image"
"image/png"
"io/ioutil"

"gopkg.in/auyer/steganography.v2"
Expand All @@ -46,7 +46,7 @@ Note that the minnimum image size is 24 pixels for one byte. For each additional
```go
inFile, _ := os.Open("input_file.png") // opening file
reader := bufio.NewReader(inFile) // buffer reader
img, _, _ := image.Decode(reader) // decoding to golang's image.Image
img, _ := png.Decode(reader) // decoding to golang's image.Image

w := new(bytes.Buffer) // buffer that will recieve the results
err := steganography.Encode(w, img, []byte("message")) // Encode the message into the image
Expand All @@ -58,6 +58,7 @@ outFile, _ := os.Create("out_file.png") // create file
w.WriteTo(outFile) // write buffer to it
outFile.Close()
```
note: all error checks were removed for brevity, but they should be included.

Size of Message
------
Expand All @@ -73,17 +74,18 @@ Read mode is used to read an image that has been encoded using LSB steganography

```go
inFile, _ := os.Open(encodedInputFile) // opening file
inFile.Close()
defer inFile.Close()

reader := bufio.NewReader(inFile) // buffer reader
img, _, _ := image.Decode(reader) // decoding to golang's image.Image
img, _ := png.Decode(reader) // decoding to golang's image.Image

sizeOfMessage := GetMessageSizeFromImage(img) // retrieving message size to decode in the next line

msg := Decode(sizeOfMessage, img) // decoding the message from the file
fmt.Println(string(msg))

```
note: all error checks were removed for brevity, but they should be included.

Complete Example
------
Expand All @@ -92,7 +94,7 @@ For a complete example, see the [examples/stego.go](examples/stego.go) file. It
----
### V1 Compatibility:

It is highly recommended for past users to upgrade to v2, but old users can still use it with:
It is highly recommended for past users to upgrade to v2, but users can still use the v1 release with:
```
import "gopkg.in/auyer/steganography.v1"
```
Expand Down

0 comments on commit 1aa26d8

Please sign in to comment.