mirror of
https://github.com/cedricbonhomme/Stegano.git
synced 2025-05-12 17:18:30 +02:00
Python 2 compatibility for exifHeader.
This commit is contained in:
parent
1def5672ab
commit
fef2040fca
4 changed files with 26 additions and 12 deletions
15
bin/lsb
15
bin/lsb
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3.5
|
||||||
#-*- coding: utf-8 -*-
|
#-*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Stéganô - Stéganô is a basic Python Steganography module.
|
# Stéganô - Stéganô is a basic Python Steganography module.
|
||||||
|
@ -78,8 +78,15 @@ if options.hide:
|
||||||
elif options.reveal:
|
elif options.reveal:
|
||||||
secret = lsb.reveal(options.input_image_file)
|
secret = lsb.reveal(options.input_image_file)
|
||||||
if options.secret_binary != "":
|
if options.secret_binary != "":
|
||||||
data = tools.base642binary(secret)
|
data = tools.base642binary(bytes(secret, "utf-8"))
|
||||||
with open(options.secret_binary, "w") as f:
|
from PIL import Image
|
||||||
f.write(data)
|
import io
|
||||||
|
file_like = io.BytesIO(data)
|
||||||
|
file_like.seek(0)
|
||||||
|
image = Image.open(file_like)
|
||||||
|
image.save(options.secret_binary)
|
||||||
|
"""data = tools.base642binary(bytes(secret, "utf-8)"))
|
||||||
|
with open(options.secret_binary, "wb") as f:
|
||||||
|
f.write(data)"""
|
||||||
else:
|
else:
|
||||||
print(secret)
|
print(secret)
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
|
||||||
__author__ = "Cedric Bonhomme"
|
__author__ = "Cedric Bonhomme"
|
||||||
__version__ = "$Revision: 0.2 $"
|
__version__ = "$Revision: 0.2.1 $"
|
||||||
__date__ = "$Date: 2016/05/17 $"
|
__date__ = "$Date: 2016/05/26 $"
|
||||||
__license__ = "GPLv3"
|
__license__ = "GPLv3"
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
@ -36,10 +36,12 @@ def hide(input_image_file, img_enc, secret_message = None, secret_file = None):
|
||||||
|
|
||||||
if secret_file != None:
|
if secret_file != None:
|
||||||
with open(secret_file, "r") as f:
|
with open(secret_file, "r") as f:
|
||||||
secret_file_content = f.read()
|
secret_message = f.read()
|
||||||
text = compress(b64encode(bytes(secret_file_content, "utf-8")))
|
|
||||||
else:
|
try:
|
||||||
text = compress(b64encode(bytes(secret_message, "utf-8")))
|
text = compress(b64encode(bytes(secret_message, "utf-8")))
|
||||||
|
except:
|
||||||
|
text = compress(b64encode(secret_message))
|
||||||
|
|
||||||
img = Image.open(input_image_file)
|
img = Image.open(input_image_file)
|
||||||
if "exif" in img.info:
|
if "exif" in img.info:
|
||||||
|
|
|
@ -181,8 +181,8 @@ if __name__ == '__main__':
|
||||||
elif options.reveal:
|
elif options.reveal:
|
||||||
secret = reveal(options.input_image_file)
|
secret = reveal(options.input_image_file)
|
||||||
if options.secret_binary != "":
|
if options.secret_binary != "":
|
||||||
data = tools.base642binary(secret)
|
data = tools.base642binary(bytes(secret, "utf-8)"))
|
||||||
with open(options.secret_binary, "w") as f:
|
with open(options.secret_binary, "wb") as f:
|
||||||
f.write(data)
|
f.write(data)
|
||||||
else:
|
else:
|
||||||
print(secret)
|
print(secret)
|
||||||
|
|
|
@ -107,4 +107,9 @@ def base642binary(b64_fname):
|
||||||
#b64_str = fin.read()
|
#b64_str = fin.read()
|
||||||
#fin.close()
|
#fin.close()
|
||||||
# Decode base64 string to original binary sound object
|
# Decode base64 string to original binary sound object
|
||||||
return base64.b64decode(b64_fname)
|
missing_padding = 4 - len(b64_fname) % 4
|
||||||
|
if missing_padding:
|
||||||
|
b64_fname += b'='* missing_padding
|
||||||
|
return base64.decodestring(b64_fname)
|
||||||
|
|
||||||
|
#return base64.b64decode(b64_fname)
|
||||||
|
|
Loading…
Add table
Reference in a new issue