隐写术是一门以这样的方式编写隐藏消息的艺术和科学,除了发送者和预期接收者之外,没有人怀疑消息的存在,这是一种通过隐匿性实现安全的形式。 因此,Stéganô 提供的功能仅隐藏消息,而不加密。 隐写术通常与密码学一起使用。
Stegano是一个纯粹的Python隐写模块。
隐写术是以这种方式编写隐藏信息的艺术和科学 除了发件人和预期收件人之外,没有人怀疑 消息的存在,一种通过默默无闻的安全形式。 因此,Stegano 提供的功能仅隐藏消息, 没有加密。隐写术通常与密码学一起使用。
Stegano 实现了以下隐藏方法:
此外,还提供了一些隐写分析方法:
pip install Stegano
您将能够在 Python 程序中使用 Stéganô 或作为命令行工具。
安装的要求:
Python 3.11.0 (main, Oct 31 2022, 15:15:22) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from stegano import lsb
>>> secret = lsb.hide("./tests/sample-files/Lenna.png", "Hello world!")
>>> secret.save("./Lenna-secret.png")
>>> print(lsb.reveal("./Lenna-secret.png"))
Hello world!
使用集合来选择将隐藏消息的像素。
Python 3.11.0 (main, Oct 31 2022, 15:15:22) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from stegano import lsb
>>> from stegano.lsb import generators
# Hide a secret with the Sieve of Eratosthenes
>>> secret_message = "Hello World!"
>>> 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 = lsb.reveal("./image.png", generators.fibonacci())
Traceback (most recent call last):
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 = lsb.reveal("./image.png", generators.eratosthenes())
>>> message
'Hello World!'
>>> # Generators available
>>> import inspect
>>> all_generators = inspect.getmembers(generators, inspect.isfunction)
>>> for generator in all_generators:
... print(generator[0], generator[1].__doc__)
...
Dead_Man_Walking None
OEIS_A000217
http://oeis.org/A000217
Triangular numbers: a(n) = C(n+1,2) = n(n+1)/2 = 0+1+2+...+n.
ackermann
Ackermann number.
carmichael None
eratosthenes
Generate the prime numbers with the sieve of Eratosthenes.
eratosthenes_composite
Generate the composite numbers with the sieve of Eratosthenes.
fermat
Generate the n-th Fermat Number.
fibonacci
A generator for Fibonacci numbers, goes to next number in series on each call.
This generator start at 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, ...
See: http://oeis.org/A000045
identity
f(x) = x
log_gen
Logarithmic generator.
mersenne
Generate 2^n-1.
syracuse
Generate the sequence of Syracuse.
shi_tomashi Shi-Tomachi corner generator of the given points
https://docs.opencv.org/4.x/d4/d8c/tutorial_py_shi_tomasi.html
triangular_numbers Triangular numbers: a(n) = C(n+1,2) = n(n+1)/2 = 0+1+2+...+n.
http://oeis.org/A000217
For JPEG and TIFF images:
Python 3.11.0 (main, Oct 31 2022, 15:15:22) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from stegano import exifHeader
>>> secret = exifHeader.hide("./tests/sample-files/20160505T130442.jpg",
"./image.jpg", secret_message="Hello world!")
>>> print(exifHeader.reveal("./image.jpg"))