Acme-Steganography-Image-Png
view release on metacpan or search on metacpan
my $self = shift;
$self->section(0);
$self->offset(0);
$self->datum_length($self->calculate_datum_length());
my $type = $self->type;
my $filename_generator
= $self->filename_generator || \&default_filename_generator;
my @filenames;
my ($filename, $state);
while (!$self->done()) {
my $image = $self->generate_next_image;
($filename, $state) = &$filename_generator($state);
$filename .= $self->suffix;
$image->write(file => $filename, type=> $type);
push @filenames, $filename;
}
@filenames;
}
# package method
sub read_files {
my $class = shift;
# This is intentionally a "sparse" array to avoid some "interesting" DOS
# possibilities.
my $length;
my %got;
foreach my $file (@_) {
my $img = new Imager;
$img->open(file => $file) or carp "Can't read '$file': " . $img->errstr;
my $payload = $class->extract_payload($img);
my $datum;
my $section;
($section, $datum) = unpack "wa*", $payload;
if ($section == 0) {
# Oops. Strip off the length.
($length, $datum) = unpack "wa*", $datum;
}
$got{$section} = $datum;
}
carp "Did not find first section in files @_" unless defined $length;
my $data = join '', map {$got{$_}} sort {$a <=> $b} keys %got;
substr ($data, $length) = '';
$data;
}
1;
__END__
=head1 NAME
Acme::Steganography::Image::Png - hide data (badly) in Png images
=head1 SYNOPSIS
use Acme::Steganography::Image::Png;
# Write your data out as RGB PNGs hidden in the image "Camouflage.jpg"
my $writer = Acme::Steganography::Image::Png::RGB::556FS->new();
$writer->data(\$data);
my @filenames = $writer->write_images("Camouflage.jpg");
# Returns a list of the filenames it wrote to
# Then read them back.
my $reread =
Acme::Steganography::Image::Png::RGB::556->read_files(@files);
=head1 DESCRIPTION
Acme::Steganography::Image::Png is extremely ineffective at hiding your
secrets inside Png images.
There are 4 implementations
=over 4
=item Acme::Steganography::Image::Png::FlashingNeonSignGrey
Blatantly stuffs your data into greyscale PNG files with absolutely no attempt
to hide it.
=item Acme::Steganography::Image::Png::RGB::556
Stuffs your data into a sample image, using the low order bits of each colour.
2 bytes of your data are stored in each pixel, 5 bits in Red and Green, 6 in
Blue. It produces a rather grainy image.
=item Acme::Steganography::Image::Png::RGB::323
Also stuffs your data into a sample image, using the low order bits of each
colour. Only 1 byte of your data is stored in each pixel, 3 bits in Red and
Blue, 2 in Green. To the untrained eye the image looks good. But the fact
that it's PNG will make anyone suspicious about the contents.
=item Acme::Steganography::Image::Png::RGB::556FS
Stuffs your data into a sample image, using the low order bits of each colour.
2 bytes of your data are stored in each pixel, 5 bits in Red and Green, 6 in
Blue. Changing the value of pixels to store data is adding error to the image,
in this case rather a lot of error. To attempt to conceal some of the
graininess Floyd-Steinberg dithering is used to spread the errors around. It's
not perfect, but effects are quite interesting, producing a reasonably nice
dithered image.
=back
Write your data out by calling C<write_images>
Read your data back in by calling C<read_files>
You don't have to return the filenames in the correct order.
=head1 BUGS
Virtually no documentation. There's the source code...
Not very many tests.
Not robust against missing files when re-reading
If you want real steganography, you're in the wrong place.
( run in 1.480 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )