-SHMÚ fetch
+Text-to-image (tti) writer
The least significant bit writer.
copyright 2024, David Polakovic, licensed under GPLv3
This script encodes message into a pictures. It utilizes very
common approach of writing information in the least significant
bits of the image pixels. You can check your message by performing
-a hexdump on the image.
+a hexdump on the image or by opening the image in a text editor.
HOW TO RUN:
Navigate to the directory where you downloaded the script and
then use:
perl tti.pl [file] <your> <message> <goes> <here> ...
+example:
+ perl tti.pl flower.png This is the secret message.
+
+New file will be saved in the same directory as the original file,
+with "-processed" handle.
LICENSE:
}
# save the filename
-my $filename = $ARGV[0];
+my $file_name = $ARGV[0];
+my $file_extension;
+
+if ($file_name =~ /^(.+)(\.[^.]+)$/) {
+ $file_extension = $2; # ".jpg"
+ $file_name = $1; # "flower"
+} else {
+ # Handle case where there's no extension
+ $file_extension = "";
+}
# save the message
shift(@ARGV);
my $message = join(" ", @ARGV);
# create name for output file
-my $new_filename = "processed_" . $filename;
+my $new_file_name = $file_name . "-processed" . $file_extension;
+
+# revert back to original name once new name is created
+$file_name = $file_name . $file_extension;
# copy the file
if ($^O eq 'MSWin32' or $^O eq 'MSWin64') {
# for Windows
- system("copy", $filename, $new_filename);
+ system("copy", $file_name, $new_file_name);
} else {
# for every other system
- system("cp", $filename, $new_filename);
+ system("cp", $file_name, $new_file_name);
}
# write the message into new file
-open my $fh, '>>:raw', $new_filename or die "Cannot open file: $!";
+open my $fh, '>>:raw', $new_file_name or die "Cannot open file: $!";
print $fh $message;
close $fh;