mirror of
https://github.com/cedricbonhomme/Stegano.git
synced 2025-05-18 11:28:31 +02:00
Updated CHANGELOG.
This commit is contained in:
parent
e490e32791
commit
75c51d40fe
20 changed files with 89 additions and 92 deletions
|
@ -1,18 +1,28 @@
|
||||||
|
ci:
|
||||||
|
autoupdate_schedule: monthly
|
||||||
repos:
|
repos:
|
||||||
|
- repo: https://github.com/adamchainz/django-upgrade
|
||||||
|
rev: 1.13.0
|
||||||
|
hooks:
|
||||||
|
- id: django-upgrade
|
||||||
|
args: [--target-version, '4.2']
|
||||||
- repo: https://github.com/asottile/pyupgrade
|
- repo: https://github.com/asottile/pyupgrade
|
||||||
rev: v2.31.1
|
rev: v3.3.1
|
||||||
hooks:
|
hooks:
|
||||||
- id: pyupgrade
|
- id: pyupgrade
|
||||||
args: ["--py37-plus"]
|
args: ["--py37-plus"]
|
||||||
- repo: https://github.com/asottile/reorder_python_imports
|
- repo: https://github.com/PyCQA/isort
|
||||||
rev: v3.0.1
|
rev: 5.12.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: reorder-python-imports
|
- id: isort
|
||||||
additional_dependencies: ["setuptools>60.9"]
|
|
||||||
- repo: https://github.com/psf/black
|
- repo: https://github.com/psf/black
|
||||||
rev: 22.3.0
|
rev: 22.3.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: black
|
- id: black
|
||||||
|
- repo: https://github.com/asottile/blacken-docs
|
||||||
|
rev: 1.13.0
|
||||||
|
hooks:
|
||||||
|
- id: blacken-docs
|
||||||
- repo: https://github.com/PyCQA/flake8
|
- repo: https://github.com/PyCQA/flake8
|
||||||
rev: 4.0.1
|
rev: 4.0.1
|
||||||
hooks:
|
hooks:
|
||||||
|
@ -20,7 +30,7 @@ repos:
|
||||||
additional_dependencies:
|
additional_dependencies:
|
||||||
- flake8-bugbear
|
- flake8-bugbear
|
||||||
- flake8-implicit-str-concat
|
- flake8-implicit-str-concat
|
||||||
args: ["--max-line-length=100"]
|
args: ["--max-line-length=125"]
|
||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
rev: v4.1.0
|
rev: v4.1.0
|
||||||
hooks:
|
hooks:
|
||||||
|
@ -31,4 +41,3 @@ repos:
|
||||||
rev: v2.5.6
|
rev: v2.5.6
|
||||||
hooks:
|
hooks:
|
||||||
- id: pip-audit
|
- id: pip-audit
|
||||||
args: ["--ignore-vuln", "PYSEC-2022-203"]
|
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
## Release History
|
## Release History
|
||||||
|
|
||||||
|
|
||||||
|
### 0.11.2 (2023-05-23)
|
||||||
|
|
||||||
|
* improved typing of various functions;
|
||||||
|
* updated dependencies.
|
||||||
|
|
||||||
|
|
||||||
### 0.11.1 (2022-11-20)
|
### 0.11.1 (2022-11-20)
|
||||||
|
|
||||||
* Fixed a bug in the command line when no sub-command is specified.
|
* Fixed a bug in the command line when no sub-command is specified.
|
||||||
|
|
19
bin/lsb.py
19
bin/lsb.py
|
@ -1,8 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
# Stegano - Stegano is a pure Python steganography module.
|
# Stegano - Stegano is a pure Python steganography module.
|
||||||
# Copyright (C) 2010-2022 Cédric Bonhomme - https://www.cedricbonhomme.org
|
# Copyright (C) 2010-2023 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||||
#
|
#
|
||||||
# For more information : https://github.com/cedricbonhomme/Stegano
|
# For more information : https://github.com/cedricbonhomme/Stegano
|
||||||
#
|
#
|
||||||
|
@ -26,6 +24,7 @@ __revision__ = "$Date: 2019/06/04 $"
|
||||||
__license__ = "GPLv3"
|
__license__ = "GPLv3"
|
||||||
|
|
||||||
import inspect
|
import inspect
|
||||||
|
|
||||||
import crayons
|
import crayons
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -34,10 +33,10 @@ try:
|
||||||
except Exception:
|
except Exception:
|
||||||
print("Install stegano: pipx install Stegano")
|
print("Install stegano: pipx install Stegano")
|
||||||
|
|
||||||
from stegano import tools
|
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
|
from stegano import tools
|
||||||
|
|
||||||
|
|
||||||
class ValidateGenerator(argparse.Action):
|
class ValidateGenerator(argparse.Action):
|
||||||
def __call__(self, parser, args, values, option_string=None):
|
def __call__(self, parser, args, values, option_string=None):
|
||||||
|
@ -76,7 +75,7 @@ def main():
|
||||||
choices=tools.ENCODINGS.keys(),
|
choices=tools.ENCODINGS.keys(),
|
||||||
default="UTF-8",
|
default="UTF-8",
|
||||||
help="Specify the encoding of the message to hide."
|
help="Specify the encoding of the message to hide."
|
||||||
+ " UTF-8 (default) or UTF-32LE.",
|
" UTF-8 (default) or UTF-32LE.",
|
||||||
)
|
)
|
||||||
|
|
||||||
# Generator
|
# Generator
|
||||||
|
@ -131,7 +130,7 @@ def main():
|
||||||
choices=tools.ENCODINGS.keys(),
|
choices=tools.ENCODINGS.keys(),
|
||||||
default="UTF-8",
|
default="UTF-8",
|
||||||
help="Specify the encoding of the message to reveal."
|
help="Specify the encoding of the message to reveal."
|
||||||
+ " UTF-8 (default) or UTF-32LE.",
|
" UTF-8 (default) or UTF-32LE.",
|
||||||
)
|
)
|
||||||
|
|
||||||
# Generator
|
# Generator
|
||||||
|
@ -179,7 +178,7 @@ def main():
|
||||||
generator = getattr(generators, arguments.generator_function[0])()
|
generator = getattr(generators, arguments.generator_function[0])()
|
||||||
|
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
print("Unknown generator: {}".format(arguments.generator_function))
|
print(f"Unknown generator: {arguments.generator_function}")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
if arguments.command == "hide":
|
if arguments.command == "hide":
|
||||||
|
@ -223,6 +222,6 @@ def main():
|
||||||
all_generators = inspect.getmembers(generators, inspect.isfunction)
|
all_generators = inspect.getmembers(generators, inspect.isfunction)
|
||||||
for generator in all_generators:
|
for generator in all_generators:
|
||||||
print("Generator id:")
|
print("Generator id:")
|
||||||
print(" {}".format(crayons.green(generator[0], bold=True)))
|
print(f" {crayons.green(generator[0], bold=True)}")
|
||||||
print("Desciption:")
|
print("Desciption:")
|
||||||
print(" {}".format(generator[1].__doc__))
|
print(f" {generator[1].__doc__}")
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
# Stegano - Stegano is a pure Python steganography module.
|
# Stegano - Stegano is a pure Python steganography module.
|
||||||
# Copyright (C) 2010-2022 Cédric Bonhomme - https://www.cedricbonhomme.org
|
# Copyright (C) 2010-2023 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||||
#
|
#
|
||||||
# For more information : https://github.com/cedricbonhomme/Stegano
|
# For more information : https://github.com/cedricbonhomme/Stegano
|
||||||
#
|
#
|
||||||
|
@ -24,10 +22,10 @@ __version__ = "$Revision: 0.7 $"
|
||||||
__date__ = "$Date: 2016/08/25 $"
|
__date__ = "$Date: 2016/08/25 $"
|
||||||
__license__ = "GPLv3"
|
__license__ = "GPLv3"
|
||||||
|
|
||||||
from PIL import Image
|
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
|
from PIL import Image
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from stegano.steganalysis import parity
|
from stegano.steganalysis import parity
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
# Stegano - Stegano is a pure Python steganography module.
|
# Stegano - Stegano is a pure Python steganography module.
|
||||||
# Copyright (C) 2010-2022 Cédric Bonhomme - https://www.cedricbonhomme.org
|
# Copyright (C) 2010-2023 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||||
#
|
#
|
||||||
# For more information : https://github.com/cedricbonhomme/Stegano
|
# For more information : https://github.com/cedricbonhomme/Stegano
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
# Stegano - Stegano is a pure Python steganography module.
|
# Stegano - Stegano is a pure Python steganography module.
|
||||||
# Copyright (C) 2010-2022 Cédric Bonhomme - https://www.cedricbonhomme.org
|
# Copyright (C) 2010-2023 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||||
#
|
#
|
||||||
# For more information : https://github.com/cedricbonhomme/Stegano
|
# For more information : https://github.com/cedricbonhomme/Stegano
|
||||||
#
|
#
|
||||||
|
@ -25,10 +23,10 @@ __date__ = "$Date: 2016/08/26 $"
|
||||||
__revision__ = "$Date: 2016/08/26 $"
|
__revision__ = "$Date: 2016/08/26 $"
|
||||||
__license__ = "GPLv3"
|
__license__ = "GPLv3"
|
||||||
|
|
||||||
from PIL import Image
|
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
|
from PIL import Image
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from stegano.steganalysis import statistics
|
from stegano.steganalysis import statistics
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Stéganô documentation build configuration file, created by
|
# Stéganô documentation build configuration file, created by
|
||||||
# sphinx-quickstart on Wed Jul 25 13:33:39 2012.
|
# sphinx-quickstart on Wed Jul 25 13:33:39 2012.
|
||||||
|
@ -10,17 +9,13 @@
|
||||||
#
|
#
|
||||||
# All configuration values have a default; values that are commented out
|
# All configuration values have a default; values that are commented out
|
||||||
# serve to show the default.
|
# serve to show the default.
|
||||||
|
|
||||||
# If extensions (or modules to document with autodoc) are in another directory,
|
# If extensions (or modules to document with autodoc) are in another directory,
|
||||||
# add these directories to sys.path here. If the directory is relative to the
|
# add these directories to sys.path here. If the directory is relative to the
|
||||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||||
# sys.path.insert(0, os.path.abspath('.'))
|
# sys.path.insert(0, os.path.abspath('.'))
|
||||||
|
|
||||||
# -- General configuration -----------------------------------------------------
|
# -- General configuration -----------------------------------------------------
|
||||||
|
|
||||||
# If your documentation needs a minimal Sphinx version, state it here.
|
# If your documentation needs a minimal Sphinx version, state it here.
|
||||||
# needs_sphinx = '1.0'
|
# needs_sphinx = '1.0'
|
||||||
|
|
||||||
# Add any Sphinx extension module names here, as strings. They can be extensions
|
# Add any Sphinx extension module names here, as strings. They can be extensions
|
||||||
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
||||||
extensions = []
|
extensions = []
|
||||||
|
@ -39,7 +34,7 @@ master_doc = "index"
|
||||||
|
|
||||||
# General information about the project.
|
# General information about the project.
|
||||||
project = "Stegano"
|
project = "Stegano"
|
||||||
copyright = "2010-2022, Cédric Bonhomme"
|
copyright = "2010-2023, Cédric Bonhomme"
|
||||||
author = "Cédric Bonhomme <cedric@cedricbonhomme.org>"
|
author = "Cédric Bonhomme <cedric@cedricbonhomme.org>"
|
||||||
|
|
||||||
# The version info for the project you're documenting, acts as replacement for
|
# The version info for the project you're documenting, acts as replacement for
|
||||||
|
@ -170,6 +165,6 @@ latex_documents = [
|
||||||
latex_show_urls = True
|
latex_show_urls = True
|
||||||
latex_show_pagerefs = True
|
latex_show_pagerefs = True
|
||||||
|
|
||||||
ADDITIONAL_PREAMBLE = """
|
ADDITIONAL_PREAMBLE = r"""
|
||||||
\setcounter{tocdepth}{3}
|
\setcounter{tocdepth}{3}
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "stegano"
|
name = "stegano"
|
||||||
version = "0.11.1"
|
version = "0.11.2"
|
||||||
description = "A pure Python Steganography module."
|
description = "A pure Python Steganography module."
|
||||||
authors = [
|
authors = [
|
||||||
"Cédric Bonhomme <cedric@cedricbonhomme.org>"
|
"Cédric Bonhomme <cedric@cedricbonhomme.org>"
|
||||||
|
@ -76,3 +76,6 @@ show_error_context = true
|
||||||
pretty = true
|
pretty = true
|
||||||
|
|
||||||
exclude = "build|dist|docs|stegano.egg-info"
|
exclude = "build|dist|docs|stegano.egg-info"
|
||||||
|
|
||||||
|
[tool.isort]
|
||||||
|
profile = "black"
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
# Stegano - Stegano is a pure Python steganography module.
|
# Stegano - Stegano is a pure Python steganography module.
|
||||||
# Copyright (C) 2010-2022 Cédric Bonhomme - https://www.cedricbonhomme.org
|
# Copyright (C) 2010-2023 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||||
#
|
#
|
||||||
# For more information : https://git.sr.ht/~cedric/stegano
|
# For more information : https://git.sr.ht/~cedric/stegano
|
||||||
#
|
#
|
||||||
|
@ -26,6 +24,7 @@ __revision__ = "$Date: 2017/01/18 $"
|
||||||
__license__ = "GPLv3"
|
__license__ = "GPLv3"
|
||||||
|
|
||||||
import piexif
|
import piexif
|
||||||
|
|
||||||
from stegano import tools
|
from stegano import tools
|
||||||
|
|
||||||
|
|
||||||
|
@ -37,11 +36,11 @@ def hide(
|
||||||
img_format=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
|
from base64 import b64encode
|
||||||
|
from zlib import compress
|
||||||
|
|
||||||
if secret_file is not None:
|
if secret_file is not None:
|
||||||
with open(secret_file, "r") as f:
|
with open(secret_file) as f:
|
||||||
secret_message = f.read()
|
secret_message = f.read()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# Stegano - Stegano is a pure Python steganography module.
|
# Stegano - Stegano is a pure Python steganography module.
|
||||||
# Copyright (C) 2010-2022 Cédric Bonhomme - https://www.cedricbonhomme.org
|
# Copyright (C) 2010-2023 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||||
#
|
#
|
||||||
# For more information : https://git.sr.ht/~cedric/stegano
|
# For more information : https://git.sr.ht/~cedric/stegano
|
||||||
#
|
#
|
||||||
|
@ -24,10 +24,11 @@ __revision__ = "$Date: 2021/11/29 $"
|
||||||
__license__ = "GPLv3"
|
__license__ = "GPLv3"
|
||||||
|
|
||||||
import itertools
|
import itertools
|
||||||
|
import math
|
||||||
|
from typing import Any, Dict, Iterator, List
|
||||||
|
|
||||||
import cv2
|
import cv2
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import math
|
|
||||||
from typing import Dict, Iterator, List, Any
|
|
||||||
|
|
||||||
|
|
||||||
def identity() -> Iterator[int]:
|
def identity() -> Iterator[int]:
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
# Stegano - Stegano is a pure Python steganography module.
|
# Stegano - Stegano is a pure Python steganography module.
|
||||||
# Copyright (C) 2010-2022 Cédric Bonhomme - https://www.cedricbonhomme.org
|
# Copyright (C) 2010-2023 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||||
#
|
#
|
||||||
# For more information : https://git.sr.ht/~cedric/stegano
|
# For more information : https://git.sr.ht/~cedric/stegano
|
||||||
#
|
#
|
||||||
|
@ -27,9 +25,10 @@ __license__ = "GPLv3"
|
||||||
|
|
||||||
from typing import IO, Iterator, Union
|
from typing import IO, Iterator, Union
|
||||||
|
|
||||||
from .generators import identity
|
|
||||||
from stegano import tools
|
from stegano import tools
|
||||||
|
|
||||||
|
from .generators import identity
|
||||||
|
|
||||||
|
|
||||||
def hide(
|
def hide(
|
||||||
image: Union[str, IO[bytes]],
|
image: Union[str, IO[bytes]],
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
# Stegano - Stéganô is a basic Python Steganography module.
|
# Stegano - Stéganô is a basic Python Steganography module.
|
||||||
# Copyright (C) 2010-2022 Cédric Bonhomme - https://www.cedricbonhomme.org
|
# Copyright (C) 2010-2023 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||||
#
|
#
|
||||||
# For more information : https://git.sr.ht/~cedric/stegano
|
# For more information : https://git.sr.ht/~cedric/stegano
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
# Stegano - Stegano is a pure Python steganography module.
|
# Stegano - Stegano is a pure Python steganography module.
|
||||||
# Copyright (C) 2010-2022 Cédric Bonhomme - https://www.cedricbonhomme.org
|
# Copyright (C) 2010-2023 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||||
#
|
#
|
||||||
# For more information : https://git.sr.ht/~cedric/stegano
|
# For more information : https://git.sr.ht/~cedric/stegano
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# Stegano - Stegano is a pure Python steganography module.
|
# Stegano - Stegano is a pure Python steganography module.
|
||||||
# Copyright (C) 2010-2022 Cédric Bonhomme - https://www.cedricbonhomme.org
|
# Copyright (C) 2010-2023 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||||
#
|
#
|
||||||
# For more information : https://git.sr.ht/~cedric/stegano
|
# For more information : https://git.sr.ht/~cedric/stegano
|
||||||
#
|
#
|
||||||
|
@ -24,9 +24,7 @@ __revision__ = "$Date: 2021/11/01 $"
|
||||||
__license__ = "GPLv3"
|
__license__ = "GPLv3"
|
||||||
|
|
||||||
import typing
|
import typing
|
||||||
|
from collections import Counter, OrderedDict
|
||||||
from collections import Counter
|
|
||||||
from collections import OrderedDict
|
|
||||||
|
|
||||||
|
|
||||||
def steganalyse(img):
|
def steganalyse(img):
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# Stegano - Stegano is a pure Python steganography module.
|
# Stegano - Stegano is a pure Python steganography module.
|
||||||
# Copyright (C) 2010-2022 Cédric Bonhomme - https://www.cedricbonhomme.org
|
# Copyright (C) 2010-2023 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||||
#
|
#
|
||||||
# For more information : https://git.sr.ht/~cedric/stegano
|
# For more information : https://git.sr.ht/~cedric/stegano
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
# Stegano - Stegano is a pure Python steganography module.
|
# Stegano - Stegano is a pure Python steganography module.
|
||||||
# Copyright (C) 2010-2022 Cédric Bonhomme - https://www.cedricbonhomme.org
|
# Copyright (C) 2010-2023 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||||
#
|
#
|
||||||
# For more information : https://git.sr.ht/~cedric/stegano
|
# For more information : https://git.sr.ht/~cedric/stegano
|
||||||
#
|
#
|
||||||
|
@ -25,9 +23,9 @@ __date__ = "$Date: 2016/05/17 $"
|
||||||
__revision__ = "$Date: 2017/01/18 $"
|
__revision__ = "$Date: 2017/01/18 $"
|
||||||
__license__ = "GPLv3"
|
__license__ = "GPLv3"
|
||||||
|
|
||||||
|
import io
|
||||||
import os
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
import io
|
|
||||||
|
|
||||||
from stegano import exifHeader
|
from stegano import exifHeader
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
# Stegano - Stegano is a pure Python steganography module.
|
# Stegano - Stegano is a pure Python steganography module.
|
||||||
# Copyright (C) 2010-2022 Cédric Bonhomme - https://www.cedricbonhomme.org
|
# Copyright (C) 2010-2023 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||||
#
|
#
|
||||||
# For more information : https://git.sr.ht/~cedric/stegano
|
# For more information : https://git.sr.ht/~cedric/stegano
|
||||||
#
|
#
|
||||||
|
@ -25,8 +23,9 @@ __date__ = "$Date: 2017/03/01 $"
|
||||||
__revision__ = "$Date: 2017/03/01 $"
|
__revision__ = "$Date: 2017/03/01 $"
|
||||||
__license__ = "GPLv3"
|
__license__ = "GPLv3"
|
||||||
|
|
||||||
import unittest
|
|
||||||
import itertools
|
import itertools
|
||||||
|
import unittest
|
||||||
|
|
||||||
import cv2
|
import cv2
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
|
@ -71,7 +70,7 @@ class TestGenerators(unittest.TestCase):
|
||||||
|
|
||||||
def test_eratosthenes(self):
|
def test_eratosthenes(self):
|
||||||
"""Test the Eratosthenes sieve."""
|
"""Test the Eratosthenes sieve."""
|
||||||
with open("./tests/expected-results/eratosthenes", "r") as f:
|
with open("./tests/expected-results/eratosthenes") as f:
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
tuple(itertools.islice(generators.eratosthenes(), 168)),
|
tuple(itertools.islice(generators.eratosthenes(), 168)),
|
||||||
tuple(int(line) for line in f),
|
tuple(int(line) for line in f),
|
||||||
|
@ -79,7 +78,7 @@ class TestGenerators(unittest.TestCase):
|
||||||
|
|
||||||
def test_composite(self):
|
def test_composite(self):
|
||||||
"""Test the composite sieve."""
|
"""Test the composite sieve."""
|
||||||
with open("./tests/expected-results/composite", "r") as f:
|
with open("./tests/expected-results/composite") as f:
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
tuple(itertools.islice(generators.composite(), 114)),
|
tuple(itertools.islice(generators.composite(), 114)),
|
||||||
tuple(int(line) for line in f),
|
tuple(int(line) for line in f),
|
||||||
|
@ -87,7 +86,7 @@ class TestGenerators(unittest.TestCase):
|
||||||
|
|
||||||
def test_fermat(self):
|
def test_fermat(self):
|
||||||
"""Test the Fermat generator."""
|
"""Test the Fermat generator."""
|
||||||
with open("./tests/expected-results/fermat", "r") as f:
|
with open("./tests/expected-results/fermat") as f:
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
tuple(itertools.islice(generators.fermat(), 9)),
|
tuple(itertools.islice(generators.fermat(), 9)),
|
||||||
tuple(int(line) for line in f),
|
tuple(int(line) for line in f),
|
||||||
|
@ -95,7 +94,7 @@ class TestGenerators(unittest.TestCase):
|
||||||
|
|
||||||
def test_triangular_numbers(self):
|
def test_triangular_numbers(self):
|
||||||
"""Test the Triangular numbers generator."""
|
"""Test the Triangular numbers generator."""
|
||||||
with open("./tests/expected-results/triangular_numbers", "r") as f:
|
with open("./tests/expected-results/triangular_numbers") as f:
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
tuple(itertools.islice(generators.triangular_numbers(), 54)),
|
tuple(itertools.islice(generators.triangular_numbers(), 54)),
|
||||||
tuple(int(line) for line in f),
|
tuple(int(line) for line in f),
|
||||||
|
@ -103,7 +102,7 @@ class TestGenerators(unittest.TestCase):
|
||||||
|
|
||||||
def test_mersenne(self):
|
def test_mersenne(self):
|
||||||
"""Test the Mersenne generator."""
|
"""Test the Mersenne generator."""
|
||||||
with open("./tests/expected-results/mersenne", "r") as f:
|
with open("./tests/expected-results/mersenne") as f:
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
tuple(itertools.islice(generators.mersenne(), 20)),
|
tuple(itertools.islice(generators.mersenne(), 20)),
|
||||||
tuple(int(line) for line in f),
|
tuple(int(line) for line in f),
|
||||||
|
@ -111,7 +110,7 @@ class TestGenerators(unittest.TestCase):
|
||||||
|
|
||||||
def test_carmichael(self):
|
def test_carmichael(self):
|
||||||
"""Test the Carmichael generator."""
|
"""Test the Carmichael generator."""
|
||||||
with open("./tests/expected-results/carmichael", "r") as f:
|
with open("./tests/expected-results/carmichael") as f:
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
tuple(itertools.islice(generators.carmichael(), 33)),
|
tuple(itertools.islice(generators.carmichael(), 33)),
|
||||||
tuple(int(line) for line in f),
|
tuple(int(line) for line in f),
|
||||||
|
@ -119,7 +118,7 @@ class TestGenerators(unittest.TestCase):
|
||||||
|
|
||||||
def test_ackermann_slow(self):
|
def test_ackermann_slow(self):
|
||||||
"""Test the Ackermann set."""
|
"""Test the Ackermann set."""
|
||||||
with open("./tests/expected-results/ackermann", "r") as f:
|
with open("./tests/expected-results/ackermann") as f:
|
||||||
self.assertEqual(generators.ackermann_slow(3, 1), int(f.readline()))
|
self.assertEqual(generators.ackermann_slow(3, 1), int(f.readline()))
|
||||||
self.assertEqual(generators.ackermann_slow(3, 2), int(f.readline()))
|
self.assertEqual(generators.ackermann_slow(3, 2), int(f.readline()))
|
||||||
|
|
||||||
|
@ -127,13 +126,13 @@ class TestGenerators(unittest.TestCase):
|
||||||
"""Test the Naive Ackermann generator"""
|
"""Test the Naive Ackermann generator"""
|
||||||
gen = generators.ackermann_naive(3)
|
gen = generators.ackermann_naive(3)
|
||||||
next(gen)
|
next(gen)
|
||||||
with open("./tests/expected-results/ackermann", "r") as f:
|
with open("./tests/expected-results/ackermann") as f:
|
||||||
self.assertEqual(next(gen), int(f.readline()))
|
self.assertEqual(next(gen), int(f.readline()))
|
||||||
self.assertEqual(next(gen), int(f.readline()))
|
self.assertEqual(next(gen), int(f.readline()))
|
||||||
|
|
||||||
def test_ackermann_fast(self):
|
def test_ackermann_fast(self):
|
||||||
"""Test the Ackermann set."""
|
"""Test the Ackermann set."""
|
||||||
with open("./tests/expected-results/ackermann", "r") as f:
|
with open("./tests/expected-results/ackermann") as f:
|
||||||
self.assertEqual(generators.ackermann_fast(3, 1), int(f.readline()))
|
self.assertEqual(generators.ackermann_fast(3, 1), int(f.readline()))
|
||||||
self.assertEqual(generators.ackermann_fast(3, 2), int(f.readline()))
|
self.assertEqual(generators.ackermann_fast(3, 2), int(f.readline()))
|
||||||
self.assertEqual(generators.ackermann_fast(4, 1), int(f.readline()))
|
self.assertEqual(generators.ackermann_fast(4, 1), int(f.readline()))
|
||||||
|
@ -142,13 +141,13 @@ class TestGenerators(unittest.TestCase):
|
||||||
"""Test the Ackermann generator"""
|
"""Test the Ackermann generator"""
|
||||||
gen = generators.ackermann(3)
|
gen = generators.ackermann(3)
|
||||||
next(gen)
|
next(gen)
|
||||||
with open("./tests/expected-results/ackermann", "r") as f:
|
with open("./tests/expected-results/ackermann") as f:
|
||||||
self.assertEqual(next(gen), int(f.readline()))
|
self.assertEqual(next(gen), int(f.readline()))
|
||||||
self.assertEqual(next(gen), int(f.readline()))
|
self.assertEqual(next(gen), int(f.readline()))
|
||||||
|
|
||||||
def test_LFSR(self):
|
def test_LFSR(self):
|
||||||
"""Test the LFSR generator"""
|
"""Test the LFSR generator"""
|
||||||
with open("./tests/expected-results/LFSR", "r") as f:
|
with open("./tests/expected-results/LFSR") as f:
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
tuple(itertools.islice(generators.LFSR(2**8), 256)),
|
tuple(itertools.islice(generators.LFSR(2**8), 256)),
|
||||||
tuple(int(line) for line in f),
|
tuple(int(line) for line in f),
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
# Stegano - Stegano is a pure Python steganography module.
|
# Stegano - Stegano is a pure Python steganography module.
|
||||||
# Copyright (C) 2010-2022 Cédric Bonhomme - https://www.cedricbonhomme.org
|
# Copyright (C) 2010-2023 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||||
#
|
#
|
||||||
# For more information : https://git.sr.ht/~cedric/stegano
|
# For more information : https://git.sr.ht/~cedric/stegano
|
||||||
#
|
#
|
||||||
|
@ -173,7 +171,12 @@ class TestLSB(unittest.TestCase):
|
||||||
@patch("builtins.input", return_value="n")
|
@patch("builtins.input", return_value="n")
|
||||||
def test_refuse_convert_rgb(self, input):
|
def test_refuse_convert_rgb(self, input):
|
||||||
message_to_hide = "Hello World!"
|
message_to_hide = "Hello World!"
|
||||||
with self.assertRaises(Exception):
|
# lsb.hide(
|
||||||
|
# "./tests/sample-files/Lenna-grayscale.png",
|
||||||
|
# message_to_hide,
|
||||||
|
# generators.eratosthenes(),
|
||||||
|
# )
|
||||||
|
with self.assertRaisesRegex(Exception, "Not a RGB image."):
|
||||||
lsb.hide(
|
lsb.hide(
|
||||||
"./tests/sample-files/Lenna-grayscale.png",
|
"./tests/sample-files/Lenna-grayscale.png",
|
||||||
message_to_hide,
|
message_to_hide,
|
||||||
|
@ -210,7 +213,9 @@ class TestLSB(unittest.TestCase):
|
||||||
with open("./tests/sample-files/lorem_ipsum.txt") as f:
|
with open("./tests/sample-files/lorem_ipsum.txt") as f:
|
||||||
message = f.read()
|
message = f.read()
|
||||||
message += message * 2
|
message += message * 2
|
||||||
with self.assertRaises(Exception):
|
with self.assertRaisesRegex(
|
||||||
|
Exception, "The message you want to hide is too long:"
|
||||||
|
):
|
||||||
lsb.hide("./tests/sample-files/Lenna.png", message, generators.identity())
|
lsb.hide("./tests/sample-files/Lenna.png", message, generators.identity())
|
||||||
|
|
||||||
def test_hide_and_reveal_with_bad_generator(self):
|
def test_hide_and_reveal_with_bad_generator(self):
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
# Stegano - Stegano is a pure Python steganography module.
|
# Stegano - Stegano is a pure Python steganography module.
|
||||||
# Copyright (C) 2010-2022 Cédric Bonhomme - https://www.cedricbonhomme.org
|
# Copyright (C) 2010-2023 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||||
#
|
#
|
||||||
# For more information : https://git.sr.ht/~cedric/stegano
|
# For more information : https://git.sr.ht/~cedric/stegano
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
# Stegano - Stegano is a pure Python steganography module.
|
# Stegano - Stegano is a pure Python steganography module.
|
||||||
# Copyright (C) 2010-2022 Cédric Bonhomme - https://www.cedricbonhomme.org
|
# Copyright (C) 2010-2023 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||||
#
|
#
|
||||||
# For more information : https://git.sr.ht/~cedric/stegano
|
# For more information : https://git.sr.ht/~cedric/stegano
|
||||||
#
|
#
|
||||||
|
@ -83,7 +81,7 @@ class TestTools(unittest.TestCase):
|
||||||
self.assertEqual(list(result), [(1, 2), (3, 4), (5, "X")])
|
self.assertEqual(list(result), [(1, 2), (3, 4), (5, "X")])
|
||||||
|
|
||||||
def test_binary2base64(self):
|
def test_binary2base64(self):
|
||||||
with open("./tests/expected-results/binary2base64", "r") as f:
|
with open("./tests/expected-results/binary2base64") as f:
|
||||||
expected_value = f.read()
|
expected_value = f.read()
|
||||||
value = tools.binary2base64("tests/sample-files/free-software-song.ogg")
|
value = tools.binary2base64("tests/sample-files/free-software-song.ogg")
|
||||||
self.assertEqual(expected_value, value)
|
self.assertEqual(expected_value, value)
|
||||||
|
|
Loading…
Add table
Reference in a new issue