stegage

package module
v0.9.4-beta Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2023 License: MIT Imports: 9 Imported by: 0

README

stegage

Go Reference test Go Report Card

stegage is a simple command line tool and Go library to both encrypt (with age) and conceal (with steganography) a file.

Original image Encoded image with the encrypted file inside
Original File Encoded File

How it works

encode

stegage encrypts a file (f.ex. doc.txt) with a passphrase and embeds the encrypted file inside an image (f.ex. stegage.jpeg. The resulting image stegage_encoded.png is visually identical to the original image stegage.jpeg.

┌────────────┐              ┌────────────┐
│    doc.txt │    encrypt   │ doc.txt.enc│
│            ├─────────────►│            ├────┐
│            │              │            │    │          ┌─────────────────────────────────┐
│            │              │            │    │          │              stegage_encoded.png│
└────────────┘              └────────────┘    │  stegano │                                 │
                                              │  graphy  │                                 │
          ┌─────────────────────────────────┐ ├─────────►│   ┌────────────┐                │
          │                    stegage.jpeg │ │          │   │ doc.txt.enc│                │
          │                                 │ │          │   │            │                │
          │                                 │ │          │   │            │                │
          │                                 │ │          │   │            │                │
          │                                 │ │          │   └────────────┘                │
          │                                 ├─┘          │                                 │
          │                                 │            └─────────────────────────────────┘
          │                                 │
          │                                 │
          │                                 │
          └─────────────────────────────────┘

The supported image formats for embedding are jpeg and png. The resulting image format is always png.

decode

stegage extracts the encrypted file from the embedding image and decrypts it.

┌─────────────────────────────────┐
│              stegage_encoded.png│
│                                 │                 ┌────────────┐            ┌────────────┐
│                                 │                 │ doc.txt.enc│            │    doc.txt │
│   ┌────────────┐                │  steganography  │            │  decrypt   │            │
│   │ doc.txt.enc│                ├────────────────►│            ├───────────►│            │
│   │            │                │                 │            │            │            │
│   │            │                │                 └────────────┘            └────────────┘
│   │            │                │
│   └────────────┘                │
│                                 │
└─────────────────────────────────┘

Usage

encode

Encrypt the file doc.txt and embed the encrypted payload in a copy of stegage.png. Save the copy to the file stegage_encoded.png.

⤷ stegage encode --inside stegage.png doc.txt > stegage_encoded.png 
Enter passphrase:
Confirm passphrase:

decode

Extract the encrypted payload from the file stegage_encoded.png and decrypt it. Save the decrypted payload to the file doc.txt

⤷ stegage decode stegage_encoded.png >  doc.txt
Enter passphrase:

Installation

Official binary Releases

You can download the latest release versions of stegage from the stegage release page.

Build from source

If your system has Go 1.17+:

go install github.com/revelaction/stegage/cmd...@v0.7.1-beta

Library Usage

encode

// error handling omitted for brevity. See ./cmd/stegage/main.go for a real example
image, _ := os.Open(image.png) 

passphrase:= strings.NewReader("aj4@7%8821vja")
data, _ := os.Open("doc.txt")

out, _ := os.Create("encoded.png") 

err := stegage.Encode(passphrase, data, image, out); err != nil {
	fmt.Printf("stegage: error encoding: %v", err)
}

decode

imageEncoded, _ := os.Open(image_encoded.png)
passphrase := strings.NewReader("aj4@7%8821vja")
out, _ := os.Create("doc.txt") 

err := stegage.Decode(passphrase, imageEncoded, out); err != nil {
	fmt.Printf("stegage: error decoding: %v", err)
}

Bash Completion

stegage has builtin bash autocompletion. You can enable it by putting the following bash snippet in your .bashrc file:

if hash stegage; then
	PROG=stegage source <(stegage bash)
fi

Command line options

⤷ stegage help
NAME:
   stegage - encrypt and conceal (steganography) a file

USAGE:
   stegage [global options] command [command options] [arguments...]

COMMANDS:
   encode, e  Encrypt a file with age and additionally conceal with steganography
   decode, d  Decrypt an age encrypted file inside of an image file
   bash       Dump bash complete script
   help, h    Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --help, -h  show help (default: false)

Documentation

Overview

Package stegage implements file encryption according to the age-encryption.org/v1 specification, and also steganography of the encrypted file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(password, image io.Reader, out io.Writer) error

Decode extracts the encrypted payload of a png image and decrypts the payload with the given password.

func Encode

func Encode(password, data, image io.Reader, out io.Writer) error

Encode encrypts data to the age password recipient and after that encodes with LSB steganography the encrypted payload in a copy of image.

The resulting image format is png.

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL