Added command line for steganalysis-parity.py and basic.py.

This commit is contained in:
cedricbonhomme 2010-10-05 19:03:38 +02:00
parent ae93079b99
commit 5d00f6334b
3 changed files with 38 additions and 29 deletions

View file

@ -61,19 +61,27 @@ def reveal(img):
if __name__ == '__main__':
# Point of entry in execution mode
original_image_file = "./pictures/Lenna.png"
encoded_image_file = "./pictures/Lenna_enc.png"
# at this point don't exceed 255 characters
secret_message = "Parce que je le vaut bien!"
from optparse import OptionParser
usage = "usage: %prog hide|reveal [options]"
parser = OptionParser(usage)
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)
else:
print("text too long! (don't exeed 255 characters)")
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)
elif sys.argv[1] == "reveal":
img = Image.open(options.input_image_file)
print reveal(img)

View file

@ -108,7 +108,8 @@ def reveal_slow(img):
if __name__ == '__main__':
# Point of entry in execution mode.
from optparse import OptionParser
parser = OptionParser()
usage = "usage: %prog hide|reveal [options]"
parser = OptionParser(usage)
parser.add_option("-i", "--input", dest="input_image_file",
help="Image file")
parser.add_option("-o", "--output", dest="output_image_file",
@ -127,6 +128,6 @@ if __name__ == '__main__':
img_encoded = hide(img, options.secret)
img_encoded.save(options.output_image_file)
if sys.argv[1] == "reveal":
elif sys.argv[1] == "reveal":
img = Image.open(options.input_image_file)
print reveal(img)

View file

@ -34,16 +34,16 @@ def steganalyse(img):
if __name__ == '__main__':
# Point of entry in execution mode
original_image_file = "./pictures/free.png"
encoded_image_file = "./pictures/free_enc.png"
original_image_file_steganalysed = "./pictures/free_steganalysed.png"
encoded_image_file_steganalysed = "./pictures/free_enc_steganalysed.png"
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.set_defaults(input_image_file = './pictures/Lenna.png',
output_image_file = './pictures/Lenna_steganalysed.png')
(options, args) = parser.parse_args()
img_original_image_file = Image.open(original_image_file)
img_encoded_image_file = Image.open(encoded_image_file)
img_original_image_steganalysde = steganalyse(img_original_image_file)
img_encoded_image_steganalysed = steganalyse(img_encoded_image_file)
img_original_image_steganalysde.save(original_image_file_steganalysed)
img_encoded_image_steganalysed.save(encoded_image_file_steganalysed)
input_image_file = Image.open(options.input_image_file)
output_image = steganalyse(input_image_file)
output_image.save(options.output_image_file)