From ae93079b99acc4ff36f8af89500b47c8de36d805 Mon Sep 17 00:00:00 2001 From: cedricbonhomme Date: Tue, 5 Oct 2010 18:46:43 +0200 Subject: [PATCH] Added command line for lsb-s.py. --- lsb-s.py | 40 ++++++++++++++++++++++++-------------- steganalysis-statistics.py | 2 +- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/lsb-s.py b/lsb-s.py index 92b0d76..03a275b 100755 --- a/lsb-s.py +++ b/lsb-s.py @@ -5,10 +5,12 @@ __author__ = "Cedric Bonhomme" __version__ = "$Revision: 0.1 $" __date__ = "$Date: 2010/10/01 $" -import tools +import sys from PIL import Image +import tools + def hide(img, message): """ Hide a message (string) in an image with the @@ -104,19 +106,27 @@ def reveal_slow(img): if __name__ == '__main__': - # Point of entry in execution mode - original_image_file = "./pictures/free.png" - encoded_image_file = "./pictures/free_enc.png" - secret_message = "Avec la technique LSB (Least Significant Bit) l'oeil humain (un normal ;-)) ne voit plus la difference" - with open("./Portishead_-_Deep_Water.ogg_b64.txt", "r") as f: - secret_message = f.read() + # Point of entry in execution mode. + from optparse import OptionParser + parser = OptionParser() + parser.add_option("-i", "--input", dest="input_image_file", + help="Image file") + parser.add_option("-o", "--output", dest="output_image_file", + help="Image file") + parser.add_option("-s", "--secret", dest="secret", + help="Your secret (Message, Image, Music or any binary file.)") + parser.set_defaults(input_image_file = './pictures/Lenna.png', + output_image_file = './pictures/Lenna_enc.png', + secret = 'Hello World!') - img1 = Image.open(original_image_file) - img_encoded = hide(img1, secret_message) + (options, args) = parser.parse_args() - if img_encoded: - # Save it - img_encoded.save(encoded_image_file) - # Test it - img2 = Image.open(encoded_image_file) - print reveal(img2) \ No newline at end of file + + if sys.argv[1] == "hide": + img = Image.open(options.input_image_file) + img_encoded = hide(img, options.secret) + img_encoded.save(options.output_image_file) + + if sys.argv[1] == "reveal": + img = Image.open(options.input_image_file) + print reveal(img) \ No newline at end of file diff --git a/steganalysis-statistics.py b/steganalysis-statistics.py index 2c8acb1..b1c210b 100644 --- a/steganalysis-statistics.py +++ b/steganalysis-statistics.py @@ -35,7 +35,7 @@ def steganalyse(img): return dict_colours.keys()[:30], most_common if __name__ == '__main__': - # Point of entry in execution mode + # Point of entry in execution mode. original_image_file = "./pictures/montenach.png" encoded_image_file = "./pictures/montenach_enc.png" original_image_file_steganalysed = "./pictures/montenach_steganalysed.png"