NAME

stegspace.pl

SYNOPSIS

# Hide a message in a text file.
stegspace.pl --message Hi! --haystack README

# Hide a smaller text file in a larger text file.
stegspace.pl --needle passwords.txt --haystack Bible.txt

# Retrieve the messages.
stegspace.pl --haystack README
stegspace.pl --haystack Bible.txt

# Print an error message and exit if there are not enough lines in the larger text
# file to hide the secret text without padding the end with "blank" lines.
stegspace.pl --fail  --needle Bible.txt --haystack passwords.txt

DESCRIPTION

This script inserts or reads a steganographic message in a text file, encoded as variable number of spaces at ends of lines. Each line can have 0-3 spaces at the end, encoding two bits, so one byte of the message requires four lines of the haystack file. It keeps the access and modification times of the haystack file the same as before.

For reference, a 5k text file hidden in the Bible (Project Gutenberg Douay-Rheims Version) adds spaces to the ends of lines as far as Deuteronomy 15:12, about 20k lines.

DISCLAIMER

This is just for fun, not adequate security for actually concealing passwords as in the "SYNOPSIS".

OPTIONS

-m --message

Message to hide in the haystack file.

-n --needle

Text file to hide in the haystack file.

-h --haystack

Large text file in which to hide a short message or text file.

-f --fail

Exit immediately if a warning condition occurs (e.g., not enough lines in the haystack file)

--help

Get brief help.

-M --manual

Get detailed help.

-d --debug

Print internal diagnostic and progress messages

DEPENDENCIES

warnings, strict, constant, Pod::Usage, and Getopt::Long are all in the standard library.

LIMITATIONS

It can't encode a message that includes null bytes, because it uses a zero byte (four consecutive lines with no trailing spaces) as an end of message marker.

I could remove that limitation by starting with a few lines encoding message length instead, but it's probably not worth it for a toy script like this.

AUTHOR

Jim Henry III, http://jimhenry.conlang.org/software/

LICENSE

This script is free software; you may redistribute it and/or modify it under the same terms as Perl itself.