如何使用 C 中的隐写术隐藏 PNG 中的 4 个字母数字字符?

发布于 2024-10-07 12:04:20 字数 231 浏览 2 评论 0原文

我见过一堆示例代码,它们的功能比我想要的要多得多,而且它的开销似乎比我想要的要多(也许这是不可避免的)。

我想要的只是在 PNG 文件中隐藏/检索 4 个字母的消息(单词)。这4个字母永远不会改变。它将始终是相同的 4 个字母。它的目的只是充当一种简单的指纹。我看到的所有示例似乎都非常复杂,涉及压缩文本文件等。

有谁知道已编写的与此类工作相关的示例代码吗?任何语言都可以——我的语言最终需要是 C 或 Obj-C。

I've seen a bunch of sample code that does a lot more than I want to do and it seems to have more overhead than I would like (perhaps this is unavoidable).

All I want is to hide/retrieve a 4 letter message (word) in/from a PNG file. These 4 letters will never change. It will always be the same 4 letters. It's purpose is simply to act as a simple kind of fingerprint. All of the examples I see seem very complex and involve compressing text files and such.

Does anyone know of any sample code that has been written that is relevant to this kind of endeavor? Any language is fine -- mine will eventually need to be C or Obj-C.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

So要识趣 2024-10-14 12:04:20

要隐藏文件中的数据,必须了解其中的预期内容。例如,如果您尝试隐藏内容的文件具有大面积的纯色,即使将一个像素更改为相邻颜色也可能会很明显。

如果假设单像素偏移到相邻颜色不会明显,则可以通过伪随机地将像素的每个红色、绿色或蓝色分量的 LSB 分配给一个文件中来存储 4 个字母(20 位) 20 个 bin 之一,然后计算每个 bin 中的偶数个或奇数个像素分量是否设置了 LSB。如果 bin 的奇偶校验与 bin 的所需值不匹配,则从分配给该 bin 的像素分量中任意/随机选择一个像素分量,并任意/随机地将其递增或递减 1(如果为 0,则将必须递增;如果是 FF,则递减)。

解码需要知道像素分量到 20 个 bin 的映射,但即使给出很多对未更改和已更改的文件,也不允许人们获得足够的信息来解码任意文件。

To hide data in a file, one must know something about what's expected there. If the file you're trying to hide stuff in has large areas of solid color, for example, changing even one pixel to an adjacent color could be noticeable.

If one assumes that a single-pixel shift to an adjacent color won't be noticeable, you could store 4 letters (20 bits) in a file by pseudo-randomly assigning the LSB of every red, green, or blue component of pixel to one of 20 bins, and then counting whether an even or odd number of pixel components in each bin have the LSB set. If the parity of a bin doesn't match the desired value for a bin, pick a pixel component arbitrarily/at random from among those assigned to that bin and arbitrarily/randomly increment or decrement it by one (if it's 0, you'll have to increment; if FF, decrement).

Decoding requires knowing the mapping of pixel components to the 20 bins, but even given a lot of pairs of unaltered and altered files wouldn't allow one to divine enough information to decode an arbitrary file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文