diff --git a/bin/stegano-lsb b/bin/stegano-lsb
index 5fa4681..d7dcd02 100755
--- a/bin/stegano-lsb
+++ b/bin/stegano-lsb
@@ -20,9 +20,9 @@
# along with this program. If not, see
__author__ = "Cedric Bonhomme"
-__version__ = "$Revision: 0.7 $"
+__version__ = "$Revision: 0.8 $"
__date__ = "$Date: 2016/08/04 $"
-__revision__ = "$Date: 2017/05/16 $"
+__revision__ = "$Date: 2019/06/01 $"
__license__ = "GPLv3"
try:
@@ -58,6 +58,9 @@ group_secret.add_argument("-f", dest="secret_file",
parser_hide.add_argument("-o", "--output", dest="output_image_file",
required=True, help="Output image containing the secret.")
+# Shift the message to hide
+parser_hide.add_argument("-s", "--shift", dest="shift", default=0,
+ help="Shift for the message to hide")
# Subparser: Reveal
parser_reveal = subparsers.add_parser('reveal', help='reveal help')
@@ -69,7 +72,9 @@ parser_reveal.add_argument("-e", "--encoding", dest="encoding",
" UTF-8 (default) or UTF-32LE.")
parser_reveal.add_argument("-o", dest="secret_binary",
help="Output for the binary secret (Text or any binary file).")
-
+# Shift the message to reveal
+parser_reveal.add_argument("-s", "--shift", dest="shift", default=0,
+ help="Shift for the reveal")
arguments = parser.parse_args()
@@ -81,7 +86,7 @@ if arguments.command == 'hide':
secret = tools.binary2base64(arguments.secret_file)
img_encoded = lsb.hide(arguments.input_image_file, secret,
- arguments.encoding)
+ arguments.encoding, int(arguments.shift))
try:
img_encoded.save(arguments.output_image_file)
except Exception as e:
@@ -89,7 +94,8 @@ if arguments.command == 'hide':
print(e)
elif arguments.command == 'reveal':
- secret = lsb.reveal(arguments.input_image_file, arguments.encoding)
+ secret = lsb.reveal(arguments.input_image_file, arguments.encoding,
+ int(arguments.shift))
if arguments.secret_binary != None:
data = tools.base642binary(secret)
with open(arguments.secret_binary, "wb") as f:
diff --git a/stegano/lsb/lsb.py b/stegano/lsb/lsb.py
index 8c0ac87..3cc083c 100755
--- a/stegano/lsb/lsb.py
+++ b/stegano/lsb/lsb.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# Stéganô - Stéganô is a basic Python Steganography module.
+# Stéganô - Stegano is a basic Python Steganography module.
# Copyright (C) 2010-2019 Cédric Bonhomme - https://www.cedricbonhomme.org
#
# For more information : https://github.com/cedricbonhomme/Stegano
@@ -20,9 +20,9 @@
# along with this program. If not, see
__author__ = "Cedric Bonhomme"
-__version__ = "$Revision: 0.3 $"
+__version__ = "$Revision: 0.4 $"
__date__ = "$Date: 2016/08/04 $"
-__revision__ = "$Date: 2017/05/04 $"
+__revision__ = "$Date: 2019/06/01 $"
__license__ = "GPLv3"
from typing import IO, Union
@@ -34,6 +34,7 @@ def hide(
input_image: Union[str, IO[bytes]],
message: str,
encoding: str = "UTF-8",
+ shift: int = 0,
auto_convert_rgb: bool = False,
):
"""Hide a message (string) in an image with the
@@ -72,6 +73,9 @@ def hide(
)
for row in range(height):
for col in range(width):
+ if shift != 0:
+ shift -= 1
+ continue
if index + 3 <= len_message_bits:
# Get the colour component.
@@ -97,7 +101,10 @@ def hide(
return encoded
-def reveal(input_image: Union[str, IO[bytes]], encoding="UTF-8"):
+def reveal(input_image: Union[str, IO[bytes]],
+ encoding: str = "UTF-8",
+ shift: int = 0
+):
"""Find a message in an image (with the LSB technique).
"""
img = tools.open_image(input_image)
@@ -107,7 +114,9 @@ def reveal(input_image: Union[str, IO[bytes]], encoding="UTF-8"):
limit = None
for row in range(height):
for col in range(width):
-
+ if shift != 0:
+ shift -= 1
+ continue
# pixel = [r, g, b] or [r,g,b,a]
pixel = img.getpixel((col, row))
if img.mode == "RGBA":