picamator / steganographykit
实现了多种隐写术算法
Requires
- php: ~5.6|~7.0
- ext-gd: *
- ext-zip: *
Requires (Dev)
- phpdocumentor/phpdocumentor: ~2.0
- phpunit/phpunit: ~5.5
- satooshi/php-coveralls: ~1.0
This package is not auto-updated.
Last update: 2024-09-22 07:38:05 UTC
README
主分支
开发分支
SteganographyKit 是一个包含实现多种图像隐写术算法的包。
隐写术是通过将信息嵌入其他看似无害的消息中而隐藏信息的艺术和科学 [1]。关于隐写术的概述可以在 [3]、[7] 中找到。SteganographyKit 使用 Christian Cachin [1] 描述的术语。
SteganographyKit 包含
- 最低有效位 (LSB)
- 纯隐写术
- 密钥隐写术
要求
suhosin.srand.ignore = Off
suhosin.mt_srand.ignore = Off
安装
安装 SteganographyKit 的最佳方式是使用 composer
更新您的 composer.json
{ "require": { "picamator/steganographykit": "~1.0" } }
使用方法
编码
<?php require __DIR__ . '/vendor/autoload.php'; $stegoContainer = new Picamator\SteganographyKit\StegoContainer(); // cover-image.png|.jpg - path to existing image to cover secretText // stego-image.png - path where new stegoImage should be saved $stegoContainer->encode('/path/to/cover-image.png', '/path/to/stego-image.png', 'secret test'); // output raw image $stegoContainer->renderImage();
解码
<?php require __DIR__ . '/vendor/autoload.php'; $stegoContainer = new Picamator\SteganographyKit\StegoContainer(); // stego-image.png $secretText = $stegoContainer->decode('/path/to/stego-image.png'); echo $secretText;
使用其他 stegoSystem
<?php require __DIR__ . '/vendor/autoload.php'; $stegoContainer = new Picamator\SteganographyKit\StegoContainer(); $stegoSystem = new Picamator\SteganographyKit\StegoSystem\SecretLsb(); // configure secret key $secretKey = 123456; $stegoKey = new Picamator\SteganographyKit\StegoKey\RandomKey($secretKey); $stegoSystem->setStegoKey($stegoKey); $stegoContainer->setStegoSystem($stegoSystem); // it's not necessary to set second parameter if result will put in stream $stegoContainer->encode('/path/to/cover-image.png', '', 'secret test'); // output raw image header('Content-Type: image/png'); $stegoContainer->renderImage();
最低有效位 (LSB)
LSB 方法通过修改 coverText 的最低有效位来获取 stegoText。详细描述和示例可以在 [4] 或 "Steganography in Depth" 部分中找到 [5]。
SteganographyKit 实现了以下条件的 LSB
- png 或 jpg 图像作为 coverText
- 文本作为 secretText
纯隐写术
纯隐写术是一种不需要在发送消息之前交换某些秘密信息的隐写术系统 [2]。
此外,还可以配置将用于算法的通道。例如,secretText 可以仅使用红色或绿色和蓝色或红色、绿色、蓝色。此外,通道使用的顺序也很重要。因此,通道可以解释为密钥。
注意:一些研究仅使用蓝色通道进行隐写术,因为该颜色不太被人眼感知。这样的结论基于实验 [6]。但应该持批判态度,因为首先,stegoanalyze 使用计算机技术来识别含有隐藏信息的图片,其次,数字图片是在足够光的屏幕上显示的。
密钥隐写术
对于密钥隐写术与纯隐写术相似,但用于编码解码过程的是密钥 [2]。
SteganographyKit 使用 [2] 中的方法,根据它们,密钥是伪随机生成器的种子 [8]。这样的种子用于创建 coverText 的像素坐标序列,以覆盖 secretText。
SteganogrpahyKit 实现了以下条件的密钥隐写术
- 密钥的长度限制为 4 到 8 位数字。它用作
mt_srand
函数的种子。
编码/解码算法与纯隐写术的不同之处在于
- 在 CoverText 中选择像素的方法。在纯隐写术中,它逐个获取,但在密钥隐写术中,它根据伪随机算法获取。
- 使用 RGB 通道的方法。在纯隐写术中,顺序与用户设置相同,但在密钥隐写术中,它根据像素的坐标进行更改。
如果像素坐标 X
和 Y
以及通道数组为 ['red', 'green', 'blue']
,则 'red' 将在通道数组中有 (X + Y) % 3
的索引,拥有 (X + Y) % 3
索引的通道将被移动到旧红色通道的位置。例如,X = 4, Y = 10
,那么 (2 + 10) % 3 = 2
,新的通道数组为 ['blue', 'green', 'red']
。因此,使用这种方法,secretText 将随机分布在 coverText 位上,同时也分布在通道中。
文档
- UML类图:[class.diagram.png](https://github.com/picamator/SteganographyKit/blob/HEAD/doc/uml/class.diagram.png)
- LSB编码/解码:[lsb-encode-decode.png](https://github.com/picamator/SteganographyKit/blob/HEAD/doc/uml/lsb-encode-decode.png)
- 生成的文档:[phpdoc](https://github.com/picamator/SteganographyKit/blob/HEAD/doc/phpdoc),请按照说明构建。
开发
要配置开发环境,请
- 遵循Docker安装步骤
- 在Docker容器中运行
composer install
贡献
如果您觉得这个项目值得使用,请给它加星。关注变化以查看所有活动。如果您看到改进的空间,请随时创建问题或发送pull request。这里有贡献指南。
请注意,本项目遵循贡献者行为准则。通过参与本项目及其社区,您同意遵守这些条款。
许可证
SteganographyKit遵循BSD-3-Clause许可证。有关详细信息,请参阅LICENSE文件。
参考文献
-
Christian Cachin "数字隐写术"。IBM研究,2005年2月17日,[https://www.zurich.ibm.com/~cca/papers/encyc.pdf](https://www.zurich.ibm.com/~cca/papers/encyc.pdf)
-
Zaidoon Kh. AL-Ani,A.A.Zaidan,B.B.Zaidan和Hamdan.O.Alanaz "隐写术的基本原理概述"// 计算机科学杂志,第2卷,第3期,2010年3月 http://arxiv.org/pdf/1003.4086.pdf
-
Sean-Philip Oriyano "使用隐写术避免观察:隐藏在光明之中。" IBM研究,2009年6月2日,[http://www.ibm.com/developerworks/web/library/wa-steganalysis/index.html?ca=dat](http://www.ibm.com/developerworks/web/library/wa-steganalysis/index.html?ca=dat)
-
Vijay Kumar Sharma,Vishal Shrivastava "一种改进的LSB替换算法,通过最小化检测来隐藏图像在图像中"// 理论与应用信息科学杂志,第36卷,第1期,2012年2月15日 http://www.jatit.org/volumes/Vol36No1/1Vol36No1.pdf
-
Gregory Kipper "隐写术调查指南",CRC出版社,2003年10月27日,240页 http://books.google.com.ua/books?id=qGcum1ZWkiYC&pg=PA37&source=gbs_toc_r&cad=3#v=onepage&q&f=false
-
Seling Hecht,Simon Shlaer,Maurice Henri Pirenne "能量,量子与视觉"// JGP第25卷第6期,第819-840页,1942年7月20日 http://rieke-server.physiol.washington.edu/People/Fred/Classes/532/Hecht1942.pdf
-
Ali K. Hmood,B.B. Zaidan,A.A. Zaidan和Hamid A. Jalab "图像中隐藏信息技术的概述"// 应用科学杂志,第10卷,第18期,第2094-2100页,2010年 http://scialert.net/abstract/?doi=jas.2010.2094.2100
-
Craig Buckler "如何在PHP中创建自己的随机数生成器",2012年2月8日 http://www.sitepoint.com/php-random-number-generator/