mirror of
https://github.com/cedricbonhomme/Stegano.git
synced 2025-06-28 03:06:14 +02:00
chg: [style] Reformated with black.
This commit is contained in:
parent
891051f77b
commit
a1213a9163
13 changed files with 275 additions and 184 deletions
|
@ -30,10 +30,13 @@ from stegano import tools
|
|||
|
||||
|
||||
def hide(
|
||||
input_image_file, img_enc, secret_message=None, secret_file=None, img_format=None,
|
||||
input_image_file,
|
||||
img_enc,
|
||||
secret_message=None,
|
||||
secret_file=None,
|
||||
img_format=None,
|
||||
):
|
||||
"""Hide a message (string) in an image.
|
||||
"""
|
||||
"""Hide a message (string) in an image."""
|
||||
from zlib import compress
|
||||
from base64 import b64encode
|
||||
|
||||
|
@ -64,8 +67,7 @@ def hide(
|
|||
|
||||
|
||||
def reveal(input_image_file):
|
||||
"""Find a message in an image.
|
||||
"""
|
||||
"""Find a message in an image."""
|
||||
from base64 import b64decode
|
||||
from zlib import decompress
|
||||
|
||||
|
|
|
@ -98,8 +98,7 @@ def hide(
|
|||
|
||||
|
||||
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).
|
||||
"""
|
||||
"""Find a message in an image (with the LSB technique)."""
|
||||
img = tools.open_image(input_image)
|
||||
width, height = img.size
|
||||
buff, count = 0, 0
|
||||
|
@ -128,4 +127,4 @@ def reveal(input_image: Union[str, IO[bytes]], encoding: str = "UTF-8", shift: i
|
|||
|
||||
if len(bitab) - len(str(limit)) - 1 == limit:
|
||||
img.close()
|
||||
return "".join(bitab)[len(str(limit)) + 1:]
|
||||
return "".join(bitab)[len(str(limit)) + 1 :]
|
||||
|
|
|
@ -106,8 +106,7 @@ def reveal(
|
|||
shift: int = 0,
|
||||
encoding: str = "UTF-8",
|
||||
):
|
||||
"""Find a message in an image (with the LSB technique).
|
||||
"""
|
||||
"""Find a message in an image (with the LSB technique)."""
|
||||
img = tools.open_image(input_image)
|
||||
img_list = list(img.getdata())
|
||||
width, height = img.size
|
||||
|
|
|
@ -67,14 +67,12 @@ def a2bits_list(chars: str, encoding: str = "UTF-8") -> List[str]:
|
|||
|
||||
|
||||
def bs(s: int) -> str:
|
||||
"""Converts an int to its bits representation as a string of 0's and 1's.
|
||||
"""
|
||||
"""Converts an int to its bits representation as a string of 0's and 1's."""
|
||||
return str(s) if s <= 1 else bs(s >> 1) + str(s & 1)
|
||||
|
||||
|
||||
def setlsb(component: int, bit: str) -> int:
|
||||
"""Set Least Significant Bit of a colour component.
|
||||
"""
|
||||
"""Set Least Significant Bit of a colour component."""
|
||||
return component & ~1 | int(bit)
|
||||
|
||||
|
||||
|
@ -102,8 +100,7 @@ def binary2base64(binary_file: str) -> str:
|
|||
|
||||
|
||||
def base642binary(b64_fname: str) -> bytes:
|
||||
"""Convert a printable string to a binary file.
|
||||
"""
|
||||
"""Convert a printable string to a binary file."""
|
||||
b64_fname += "==="
|
||||
return base64.b64decode(b64_fname)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue