mirror of
https://github.com/cedricbonhomme/Stegano.git
synced 2025-05-12 17:18:30 +02:00
Added command line for lsb-s.py.
This commit is contained in:
parent
c9417bddd0
commit
ae93079b99
2 changed files with 26 additions and 16 deletions
40
lsb-s.py
40
lsb-s.py
|
@ -5,10 +5,12 @@ __author__ = "Cedric Bonhomme"
|
||||||
__version__ = "$Revision: 0.1 $"
|
__version__ = "$Revision: 0.1 $"
|
||||||
__date__ = "$Date: 2010/10/01 $"
|
__date__ = "$Date: 2010/10/01 $"
|
||||||
|
|
||||||
import tools
|
import sys
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
|
import tools
|
||||||
|
|
||||||
def hide(img, message):
|
def hide(img, message):
|
||||||
"""
|
"""
|
||||||
Hide a message (string) in an image with the
|
Hide a message (string) in an image with the
|
||||||
|
@ -104,19 +106,27 @@ def reveal_slow(img):
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# Point of entry in execution mode
|
# Point of entry in execution mode.
|
||||||
original_image_file = "./pictures/free.png"
|
from optparse import OptionParser
|
||||||
encoded_image_file = "./pictures/free_enc.png"
|
parser = OptionParser()
|
||||||
secret_message = "Avec la technique LSB (Least Significant Bit) l'oeil humain (un normal ;-)) ne voit plus la difference"
|
parser.add_option("-i", "--input", dest="input_image_file",
|
||||||
with open("./Portishead_-_Deep_Water.ogg_b64.txt", "r") as f:
|
help="Image file")
|
||||||
secret_message = f.read()
|
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)
|
(options, args) = parser.parse_args()
|
||||||
img_encoded = hide(img1, secret_message)
|
|
||||||
|
|
||||||
if img_encoded:
|
|
||||||
# Save it
|
if sys.argv[1] == "hide":
|
||||||
img_encoded.save(encoded_image_file)
|
img = Image.open(options.input_image_file)
|
||||||
# Test it
|
img_encoded = hide(img, options.secret)
|
||||||
img2 = Image.open(encoded_image_file)
|
img_encoded.save(options.output_image_file)
|
||||||
print reveal(img2)
|
|
||||||
|
if sys.argv[1] == "reveal":
|
||||||
|
img = Image.open(options.input_image_file)
|
||||||
|
print reveal(img)
|
|
@ -35,7 +35,7 @@ def steganalyse(img):
|
||||||
return dict_colours.keys()[:30], most_common
|
return dict_colours.keys()[:30], most_common
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# Point of entry in execution mode
|
# Point of entry in execution mode.
|
||||||
original_image_file = "./pictures/montenach.png"
|
original_image_file = "./pictures/montenach.png"
|
||||||
encoded_image_file = "./pictures/montenach_enc.png"
|
encoded_image_file = "./pictures/montenach_enc.png"
|
||||||
original_image_file_steganalysed = "./pictures/montenach_steganalysed.png"
|
original_image_file_steganalysed = "./pictures/montenach_steganalysed.png"
|
||||||
|
|
Loading…
Add table
Reference in a new issue