stegspace.pl
# 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
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.
This is just for fun, not adequate security for actually concealing passwords as in the "SYNOPSIS".
Message to hide in the haystack file.
Text file to hide in the haystack file.
Large text file in which to hide a short message or text file.
Exit immediately if a warning condition occurs (e.g., not enough lines in the haystack file)
Get brief help.
Get detailed help.
Print internal diagnostic and progress messages
warnings
, strict
, constant
, Pod::Usage
, and Getopt::Long
are all in the standard library.
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.
Jim Henry III, http://jimhenry.conlang.org/software/
This script is free software; you may redistribute it and/or modify it under the same terms as Perl itself.