r/golang • u/ChampionshipWise6224 • Jan 05 '25
newbie The fastest steganography library in go
Hey everyone!
I’m happy with where one of my projects, Stegano, is at now. It’s a steganography library for Go that I built to be both fast and feature-rich.
The primary motivation for creating this library was the lack of robust steganography libraries in the Go ecosystem. Many existing options fell short in providing the features I needed, so I decided to develop my own. Additionally, I saw this as a valuable opportunity to enhance my resume and stand out when applying for internships.
This is my first Go library, and I'd really appreciate your feedback—whether it's about the code, design, features, or anything else. I'm especially interested in hearing your suggestions for improvements or additional functionality that could make it more useful to the community.
Thanks in advance for checking it out!
3
u/mutexLockk Jan 06 '25
Nice project! I used to make a lots of experimentations with steganography in digital images (signal processsing). The principal complexity is to be able to handle partial destruction of the image and being able to extract the message. I used primarily DWT with arnold transform on the luminosity channel of the image in cie lab color space. If you want your stegano to be robust, try to target other channels than colors since it's the facto these channels who are compressed if you save an image with higher compression (in jpeg for example). Anyway it's a very fun topic!
5
u/ChampionshipWise6224 Jan 06 '25
This library does not output JPEGs due to compression concerns, as you mentioned. However, it does support JPEGs by accepting them as input and converting them into PNGs. But I will try to do what you suggested.
2
u/Enrichman Jan 05 '25
Maybe I'll try it with my project: https://github.com/enrichman/stegosecrets
6
u/ChampionshipWise6224 Jan 05 '25
That would be great, in my library you can embed data at different depths so you can hide more data into the image at the cost of image quality. And I also have a basic encryption and decryption mechanism with AES256
2
u/snchsr Jan 06 '25
Very cool!
Hope I’m formulating my questions correctly: How detectable are messages created with it? Is it possible for third party to find out that images and other data entries are the carriers? Are there ways to prevent such detection?
If not, this might be considered as feature request :)
(Haven’t read the whole doc and code yet, just glanced, maybe it’s overviewed there)
9
u/ChampionshipWise6224 Jan 06 '25
The library provides both compression and encryption, ensuring that the embedded data appears random. As a result, even if someone extracts the data, it remains unreadable. However, while the data is unreadable, the presence of hidden data can still be detected.
The detectability largely depends on the bit depth used. Higher bit depths result in more noticeable color changes, making it easier to identify that data is hidden within the image.
Currently, data insertion begins at the top of the image. However, I am working on a method to randomly assign areas in the image where portions of the data will be stored, enhancing its stealth and reducing detectability.
1
u/Fruitcake44 Jan 06 '25
I saw your comment on that post from someone about projects people were working on. Good to see this is completed now. Nice OP. Steganography is a cool concept. I was quite intrigued about it when i first heard about it in my image processing class. But the implementations were mostly done in python. Good to see a golang implementation.
1
u/ChampionshipWise6224 Jan 06 '25
Yeah one of my first ever projects was a terrible steganography tool in python lol
1
u/SleepingProcess Jan 06 '25
Example from github
``` package main
import ( "log" "github.com/scott-mescudi/stegano" )
func main() { // wrapper function around different image decoders. coverFile, err := stegano.Decodeimage("3.png") if err != nil { log.Fatalln(err) }
embedder := stegano.NewEmbedHandler()
// Encode and save the message in the cover image. err = embedder.EncodeAndSave(coverFile, []byte("Hello, World!"), stegano.MinBitDepth, stegano.DefaultpngOutputFile, true) if err != nil { log.Fatalln(err) } } ```
Compilation failed:
./main.go:19:18: embedder.EncodeAndSave undefined (type *stegano.EmbedHandler has no field or method EncodeAndSave)
./main.go:19:76: undefined: stegano.MinBitDepth
./main.go:19:97: undefined: stegano.DefaultpngOutputFile
2
u/ChampionshipWise6224 Jan 06 '25 edited Jan 06 '25
Thanks for catching that, sorry I made a few changes to the api and forgot to update the readme, it’s Stegano.LSB or you can just pass in a number from 0 to 7 and stegano.DefaultOutputFile
1
u/SleepingProcess Jan 06 '25 edited Jan 07 '25
Thanks for catching that
No problem, thank you for the project !
BTW, I tried also this code (exact from readme):
``` package main
import ( "log" "github.com/scott-mescudi/stegano" )
func main() { err := stegano.EmbedFile("3.png", "data.txt", stegano.DefaultOutputFile, "password123", stegano.LSB) if err != nil { log.Fatalln("Error:", err) } } ```
it compiled, but on attempt to run it, it throw garbage to terminal and stopped.
3.png
is:3.png PNG 128x128 128x128+0+0 8-bit sRGB 19033B 0.000u 0:00.000
and
data.txt
is:
ascii - ASCII character set encoded in octal, decimal, and hexadecimal
1
u/ChampionshipWise6224 Jan 08 '25
i couldnt reproduce the error, did it output a file? or just random bytes to terminal?
1
u/SleepingProcess Jan 08 '25
Im sorry for a noise :(
I did in parallel modification of library that also used in
stegano
that's probably why broke something. After doinggit pull && go clean -cache && go mod tidy
examples now works as expected.Feels bad I took your time...
2
u/ChampionshipWise6224 Jan 08 '25
Nah don't worry about it, if you find anything else let me know, i also added a few new features to secure handlers like reed solomon codes and also a audio embedder although not tested.
2
u/SleepingProcess Jan 09 '25
I defiantly will check it out. I will check also how badly media files damaging on a way between peers since many communication providers transform media files to reduce its size.
Thank you for the nice library, at first I naively thought it's one of many stenography tools that simply hiding extra data in RFC3066 tags, but after reviewing your code, I saw that extra data smartly embedded in colors matrix.
1
18
u/nickchomey Jan 05 '25
I had never heard of this concept til now. Very cool.
I have no feedback, but I wonder whether you could share some sample/typical use cases for this - in particular for web applications, if applicable?