PHP图像隐写术几乎相同的开始 [英] php image steganography nearly same start

查看:112
本文介绍了PHP图像隐写术几乎相同的开始的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个php脚本,该脚本对给定的文本进行编码,并使用 LSB将其隐藏在图像中.但是编码后的文本是字节数组(使用带有rijndael-256的mcrypt加密的文本,然后使用unpack("C *",$ encryptedText)解压缩;)我已经在数组的开头添加了数组大小.如果我不这样做,那么以后再次从图像读取字节将很糟糕,因为脚本将不知道从何处停止读取.我使用以下几行代码在数组的开头添加了大小信息:

i am working on a php-script which encodes given text and hides that in an Image using LSB. But the encoded text is a Byte Array (text encrypted using mcrypt with rijndael-256 and then unpacked with unpack("C*", $encryptedText);) i have tp add the array-size at the beginning of the Array. if i would not do this, reading the Bytes from the Image again would be terrible later on, because the script would not know where to stop reading. I added size Information at the beginning of the Array using These lines of code:

$size = count($byteArray); array_unshift($byteArray, $size >> 24, ($size & 0xff0000) >> 16, ($size & 0xff00) >> 8, $size & 0xff);

$size = count($byteArray); array_unshift($byteArray, $size >> 24, ($size & 0xff0000) >> 16, ($size & 0xff00) >> 8, $size & 0xff);

因此大小以整数格式(4字节)添加,但是现在创建的每个图像都具有以下特征:第一个隐藏字节主要以零开始,因为$ size大多在60000或更小范围内.我有什么办法可以编码大小或更改程序的其他部分,以便它可以正常工作,并且每次字节头的开始都几乎不相同?

so the size is added in integer Format (4bytes), but now every Image created would have the characteristics that the first hidden Bytes start mostly with Zeros, besause $size is mostly in the range of 60000 or lower. is there any way i can encode size or Change other parts of the program so that it works and the beginning of the bytearry is not nearly the same every time?

推荐答案

您不必总是使用前4个字节来编码消息的长度,而是可以使用第一个字节中的后两位来编码所需的字节数读取$size.假设00 = 1、01 = 2、10 = 3和11 =4.例如,如果$size足够小,只能用两个字节表示,那么前几个字节将显示如下:

Instead of always having the first 4 bytes encoding how long your message is, you can use the last two bits from the first byte to encode how many bytes you need to read for $size. Say, 00 = 1, 01 = 2, 10 = 3 and 11 = 4. For example, if $size is small enough to be expressed with just two bytes, the first few bytes will read as follow:

  • 第一个字节:xxxxxx01
  • 第二个和第三个字节:$ size
  • 第四字节及以后:ByteArray ...

您可以使用随机嵌入方法进一步提高处理效果.您可以使用伪随机数生成器或混乱的地图,例如后勤地图帐篷地图.收据将要求种子或初始条件参数以什么顺序来解密以读取字节以提取消息.例如,考虑要嵌入数据的5个字节和在0和1之间生成的5个数字.

You can spice things up further by using a randomised embedding method. You can use a pseudorandom number generator, or chaotic maps, such as the Logistic Map, or Tent Map. The seed or initial condition parameters will be required by the receipt to decipher in what order to read the bytes to extract the message. For example, consider 5 bytes to embed data and 5 numbers generated between 0 and 1.

(0.2843,0.5643,0.0904,0.4308,0.9866)

(0.2843, 0.5643, 0.0904, 0.4308, 0.9866)

按数字升序排列将为您提供以下顺序,您可以使用这些顺序来嵌入您的秘密:

Sorting the numbers in ascending order gives you the following order, which you can use to embed your secret:

(3,1,4,2,5)

(3, 1, 4, 2, 5)

这篇关于PHP图像隐写术几乎相同的开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆