附加到 JPG 上的随机数据会使其无法使用吗?

发布于 2024-07-04 13:14:49 字数 569 浏览 12 评论 0原文

因此,为了简化我的生活,我希望能够在我的程序正在处理的一些 jpg 图像的末尾附加 1 到 7 个附加字符*。 这些是虚拟填充(填充符等 - 可能都是 0x00),只是为了使文件大小成为 8 字节的倍数以进行块加密。

在用几个程序尝试过这一点后,看来它们对出现在 之后的附加字符没问题。 FF D9 指定图像的结尾 - 所以看起来文件格式定义得足够好,我在末尾添加的“损坏”应该不重要。

如果需要的话,我总是可以稍后对文件进行后期处理,但我的偏好是做最简单的事情 - 即让它们保留(我正在解密其他文件类型,他们不会介意,所以有一个特殊情况很烦人)。

我认为多年前关于隐写术的喧嚣,有人在这里提出了一些意见......

(按8字节块进行加密处理,我不想保存预加密的文件大小,因此在输入数据后面附加0x00,解码后将其保留在那里)

So, to simplify my life I want to be able to append from 1 to 7 additional characters on the end of some jpg images my program is processing*. These are dummy padding (fillers, etc - probably all 0x00) just to make the file size a multiple of 8 bytes for block encryption.

Having tried this out with a few programs, it appears they are fine with the additional characters, which occur after the FF D9 that specifies the end of the image - so it appears that the file format is well defined enough that the 'corruption' I'm adding at the end shouldn't matter.

I can always post process the files later if needed, but my preference is to do the simplest thing possible - which is to let them remain (I'm decrypting other file types and they won't mind, so having a special case is annoying).

I figure with all the talk of Steganography hullaballo years ago, someone has some input here...

(encryption processing by 8 byte blocks, I don't want to save pre-encrypted file size, so append 0x00 to input data, and leave them there after decoding)

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

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

发布评论

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

评论(4

安静 2024-07-11 13:14:49

您可以将数据嵌入 JPEG 内的 XMP 标记(或 EXIF 或 IPTC 字段)。
XMP 是 XML,因此您可以灵活地进行自己的自定义操作。

这可能不是最简单的事情,但将数据放在这里将保持 JPEG 的完整性,并且不需要“后处理”。

然后,您的数据将显示在其他成像软件(例如 PhotoShop)中,这可能并不理想。

You can embed your data in the XMP tag within a JPEG (or EXIF or IPTC fields for that matter).
XMP is XML so you have a fair bit of flexibility there to do you own custom stuff.

It's probably not the simplest thing possible but putting your data here will maintain the integrity of the JPEG and require no "post processing".

You data will then show up in other imaging software such as PhotoShop, which may not be ideal.

扛刀软妹 2024-07-11 13:14:49

正如其他人所说,您无法控制程序如何处理图像文件,因此某些程序可能会发现图像有效,而其他程序可能不会。

然而,这里有一个更大的问题。 从你的问题来看,我推断你正在实践“通过默默无闻的安全”。 人们普遍认为这是一种非常糟糕的做法。 使用 Google 查找大量有关该主题的文章。

As others have stated, you have no control how programs process image files and therefore some programs may find the images valid others may not.

However, there is a bigger issue here. Judging by your question, I'm deducing you're practicing "security through obscurity." It's widely considered a very bad practice. Use Google to find a plethora of articles about the topic.

歌枕肩 2024-07-11 13:14:49

您可以..但结果可能是不可预测的。

尽管格式中有足够的信息告诉客户端忽略额外的数据,但这可能不是程序员测试的情况。

偏执的程序可能会查看大小,注意到差异并决定不会处理您的文件,因为显然它不完全理解它。 当从网络读取数据时,文件中的随机字节可能被视为安全风险,这种情况尤其可能发生。

You can .. but the results may be unpredictable.

Even though there is enough information in the format to tell the client to ignore the extra data it is likely not a case the programmer tested for.

A paranoid program might look at the size, notice the discrepancy and decide it won't process your file because clearly it doesn't fully understand it. This is particularly likely when reading data from the web when random bytes in a file could be considered a security risk.

倒带 2024-07-11 13:14:49

不,您可以在 jpg 文件的末尾添加位,而不会使其无法使用。 jpg 文件的标题告诉了如何读取它,因此读取它的程序将停在 jpg 数据的末尾。

事实上,人们通过将 zip 数据附加到 jpg 数据的末尾,将 zip 文件隐藏在 jpg 文件中。 由于这些格式的结构方式,生成的文件在任何一种格式下都是有效的。

No, you can add bits to the end of a jpg file, without making it unusable. The heading of the jpg file tells how to read it, so the program reading it will stop at the end of the jpg data.

In fact, people have hidden zip files inside jpg files by appending the zip data to the end of the jpg data. Because of the way these formats are structured, the resulting file is valid in either format.

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