Update documentation

This commit is contained in:
Flavien 2022-11-12 16:50:10 +01:00
parent 82b59f73db
commit 076a5d447f
4 changed files with 63 additions and 77 deletions

View file

@ -68,7 +68,7 @@ Secret Message
### Hide the message with the Sieve of Eratosthenes
```bash
$ stegano-lsb-set hide -i ./tests/sample-files/Lenna.png -m 'Secret Message' --generator eratosthenes -o Lena2.png
$ stegano-lsb hide -i ./tests/sample-files/Lenna.png -m 'Secret Message' --generator eratosthenes -o Lena2.png
```
The message will be scattered in the picture, following a set described by the

View file

@ -28,26 +28,31 @@ Sets are used in order to select the pixels where the message will be hidden.
Python 3.10.0 (default, Oct 17 2021, 09:02:57) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from stegano import lsbset
>>> from stegano.lsbset import generators
>>> from stegano import lsb
>>> from stegano.lsb import generators
# Hide a secret with the Sieve of Eratosthenes
>>> secret_message = "Hello World!"
>>> secret_image = lsbset.hide("./tests/sample-files/Lenna.png",
secret_message,
generators.eratosthenes())
>>> secret_image = lsb.hide("./tests/sample-files/Lenna.png", secret_message, generators.eratosthenes())
>>> secret_image.save("./image.png")
# Try to decode with another generator
>>> message = lsbset.reveal("./image.png", generators.fibonacci())
>>> message = lsb.reveal("./image.png", generators.fibonacci())
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/cedric/projects/Stegano/stegano/lsbset/lsbset.py", line 111, in reveal
for color in img_list[generated_number]:
IndexError: list index out of range
File "/Users/flavien/.local/share/virtualenvs/Stegano-sY_cwr69/bin/stegano-lsb", line 6, in <module>
sys.exit(main())
File "/Users/flavien/Perso/dev/Stegano/bin/lsb.py", line 190, in main
img_encoded = lsb.hide(
File "/Users/flavien/Perso/dev/Stegano/stegano/lsb/lsb.py", line 63, in hide
hider.encode_pixel((col, row))
File "/Users/flavien/Perso/dev/Stegano/stegano/tools.py", line 165, in encode_pixel
r, g, b, *a = self.encoded_image.getpixel(coordinate)
File "/Users/flavien/.local/share/virtualenvs/Stegano-sY_cwr69/lib/python3.10/site-packages/PIL/Image.py", line 1481, in getpixel
return self.im.getpixel(xy)
IndexError: image index out of range
# Decode with Eratosthenes
>>> message = lsbset.reveal("./image.png", generators.eratosthenes())
>>> message = lsb.reveal("./image.png", generators.eratosthenes())
>>> message
'Hello World!'

View file

@ -12,52 +12,56 @@ Display help
.. code-block:: bash
$ stegano-lsb --help
usage: stegano-lsb [-h] {hide,reveal} ...
usage: stegano-lsb [-h] {hide,reveal,list-generators} ...
positional arguments:
{hide,reveal} sub-command help
hide hide help
reveal reveal help
{hide,reveal,list-generators}
sub-command help
hide hide help
reveal reveal help
list-generators list-generators help
optional arguments:
-h, --help show this help message and exit
options:
-h, --help show this help message and exit
.. code-block:: bash
$ stegano-lsb hide --help
usage: stegano-lsb hide [-h] -i INPUT_IMAGE_FILE [-e {UTF-8,UTF-32LE}]
(-m SECRET_MESSAGE | -f SECRET_FILE) -o
OUTPUT_IMAGE_FILE
usage: stegano-lsb hide [-h] -i INPUT_IMAGE_FILE [-e {UTF-8,UTF-32LE}] [-g [GENERATOR_FUNCTION ...]] [-s SHIFT] (-m SECRET_MESSAGE | -f SECRET_FILE) -o OUTPUT_IMAGE_FILE
optional arguments:
-h, --help show this help message and exit
-i INPUT_IMAGE_FILE, --input INPUT_IMAGE_FILE
options:
-h, --help show this help message and exit
-i INPUT_IMAGE_FILE, --input INPUT_IMAGE_FILE
Input image file.
-e {UTF-8,UTF-32LE}, --encoding {UTF-8,UTF-32LE}
Specify the encoding of the message to hide. UTF-8
(default) or UTF-32LE.
-m SECRET_MESSAGE Your secret message to hide (non binary).
-f SECRET_FILE Your secret to hide (Text or any binary file).
-o OUTPUT_IMAGE_FILE, --output OUTPUT_IMAGE_FILE
-e {UTF-8,UTF-32LE}, --encoding {UTF-8,UTF-32LE}
Specify the encoding of the message to hide. UTF-8 (default) or UTF-32LE.
-g [GENERATOR_FUNCTION ...], --generator [GENERATOR_FUNCTION ...]
Generator (with optional arguments)
-s SHIFT, --shift SHIFT
Shift for the generator
-m SECRET_MESSAGE Your secret message to hide (non binary).
-f SECRET_FILE Your secret to hide (Text or any binary file).
-o OUTPUT_IMAGE_FILE, --output OUTPUT_IMAGE_FILE
Output image containing the secret.
.. code-block:: bash
$ stegano-lsb reveal --help
usage: stegano-lsb reveal [-h] -i INPUT_IMAGE_FILE [-e {UTF-8,UTF-32LE}]
[-o SECRET_BINARY]
usage: stegano-lsb reveal [-h] -i INPUT_IMAGE_FILE [-e {UTF-8,UTF-32LE}] [-g [GENERATOR_FUNCTION ...]] [-s SHIFT] [-o SECRET_BINARY]
optional arguments:
-h, --help show this help message and exit
-i INPUT_IMAGE_FILE, --input INPUT_IMAGE_FILE
options:
-h, --help show this help message and exit
-i INPUT_IMAGE_FILE, --input INPUT_IMAGE_FILE
Input image file.
-e {UTF-8,UTF-32LE}, --encoding {UTF-8,UTF-32LE}
Specify the encoding of the message to reveal. UTF-8
(default) or UTF-32LE.
-o SECRET_BINARY Output for the binary secret (Text or any binary
file).
-e {UTF-8,UTF-32LE}, --encoding {UTF-8,UTF-32LE}
Specify the encoding of the message to reveal. UTF-8 (default) or UTF-32LE.
-g [GENERATOR_FUNCTION ...], --generator [GENERATOR_FUNCTION ...]
Generator (with optional arguments)
-s SHIFT, --shift SHIFT
Shift for the generator
-o SECRET_BINARY Output for the binary secret (Text or any binary file).
Hide and reveal a text message
@ -92,63 +96,40 @@ Hide and reveal a binary file
The command ``stegano-lsb-set``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sets are used in order to select the pixels where the message will be hidden.
Hide and reveal a text message
------------------------------
Hide and reveal a text message with set
---------------------------------------
.. code-block:: bash
# Hide the message with the Sieve of Eratosthenes
$ stegano-lsb-set hide -i ./tests/sample-files/Montenach.png --generator eratosthenes -m 'Joyeux Noël!' -o ./surprise.png
$ stegano-lsb hide -i ./tests/sample-files/Montenach.png --generator eratosthenes -m 'Joyeux Noël!' -o ./surprise.png
# Try to reveal with Mersenne numbers
$ stegano-lsb-set reveal --generator mersenne -i ./surprise.png
$ stegano-lsb reveal --generator mersenne -i ./surprise.png
# Try to reveal with fermat numbers
$ stegano-lsb-set reveal --generator fermat -i ./surprise.png
$ stegano-lsb reveal --generator fermat -i ./surprise.png
# Try to reveal with carmichael numbers
$ stegano-lsb-set reveal --generator carmichael -i ./surprise.png
$ stegano-lsb reveal --generator carmichael -i ./surprise.png
# Try to reveal with Sieve of Eratosthenes
$ stegano-lsb-set reveal --generator eratosthenes -i ./surprise.png
An other example:
.. code-block:: bash
# Hide the message - LSB with a set defined by the identity function (f(x) = x).
stegano-lsb-set hide -i ./tests/sample-files/Montenach.png --generator identity -m 'I like steganography.' -o ./enc-identity.png
# Hide the message - LSB only.
stegano-lsb hide -i ./tests/sample-files/Montenach.png -m 'I like steganography.' -o ./enc.png
# Check if the two generated files are the same.
sha1sum ./enc-identity.png ./enc.png
# The output of lsb is given to lsb-set.
stegano-lsb-set reveal -i ./enc.png --generator identity
# The output of lsb-set is given to lsb.
stegano-lsb reveal -i ./enc-identity.png
$ stegano-lsb reveal --generator eratosthenes -i ./surprise.png
Sometimes it can be useful to skip the first values of a set. For example if you want
to hide several messages or because due to the selected generator
(Fibonacci starts with 0, 1, 1, etc.). Or maybe you just want to add more complexity.
In this case, simply use the optional arguments ``--shift``:
In this case, simply use the optional arguments ``--shift`` or ``-s``:
.. code-block:: bash
stegano-lsb-set reveal -i ./tests/sample-files/Lenna.png --generator fibonacci --shift 7
$ stegano-lsb hide -i ./tests/sample-files/Lenna.png -m 'Shifted secret message' -o ~/Lenna1.png --shift 7
$ stegano-lsb reveal -i ~/Lenna1.png --shift 7
Shifted secret message
List all available generators
@ -156,7 +137,7 @@ List all available generators
.. code-block:: bash
$ stegano-lsb-set list-generators
$ stegano-lsb list-generators
Generator id:
ackermann
Desciption:

View file

@ -7,7 +7,7 @@ Parity
.. code-block:: bash
# Hide the message with Sieve of Eratosthenes
stegano-lsb-set hide -i ./tests/sample-files/20160505T130442.jpg -o ./surprise.png --generator eratosthenes -m 'Very important message.'
stegano-lsb hide -i ./tests/sample-files/20160505T130442.jpg -o ./surprise.png --generator eratosthenes -m 'Very important message.'
# Steganalysis of the original photo
stegano-steganalysis-parity -i ./tests/sample-files/20160505T130442.jpg -o ./surprise_st_original.png
@ -16,4 +16,4 @@ Parity
stegano-steganalysis-parity -i ./surprise.png -o ./surprise_st_secret.png
# Reveal with Sieve of Eratosthenes
stegano-lsb-set reveal -i ./surprise.png --generator eratosthenes
stegano-lsb reveal -i ./surprise.png --generator eratosthenes