Version 0.8.

This commit is contained in:
Cédric Bonhomme 2017-05-06 23:20:54 +02:00
parent a770f402cb
commit cbb9df7675
No known key found for this signature in database
GPG key ID: A1CB94DE57B7A70D
6 changed files with 34 additions and 26 deletions

View file

@ -28,12 +28,13 @@ __license__ = "GPLv3"
import sys
from PIL import Image
from typing import Union, IO
from stegano import tools
def hide(input_image_file: str,
message,
encoding='UTF-8',
def hide(input_image: Union[str, IO[bytes]],
message: str,
encoding: str = 'UTF-8',
auto_convert_rgb: bool = False):
"""Hide a message (string) in an image with the
LSB (Least Significant Bit) technique.
@ -41,7 +42,7 @@ def hide(input_image_file: str,
message_length = len(message)
assert message_length != 0, "message length is zero"
img = Image.open(input_image_file)
img = Image.open(input_image)
if img.mode not in ['RGB', 'RGBA']:
if not auto_convert_rgb:
@ -92,10 +93,10 @@ def hide(input_image_file: str,
return encoded
def reveal(input_image_file, encoding='UTF-8'):
def reveal(input_image: Union[str, IO[bytes]], encoding='UTF-8'):
"""Find a message in an image (with the LSB technique).
"""
img = Image.open(input_image_file)
img = Image.open(input_image)
width, height = img.size
buff, count = 0, 0
bitab = []