编码、压缩

发布于 2024-10-30 05:48:49 字数 196 浏览 1 评论 0原文

我想知道

  • 文件加密算法是否可以设计成也可以执行文件压缩活动(任何实例?)。
  • 我还可以将其集成到移动短信服务(我的意思是短信)中吗?

我还想了解二进制文件...如果纯文本文件以二进制编码,它的大小会减小吗?另外,将纯文本文件编码为二进制文件比将其编码为任何其他格式更好(以防有人希望出于任何目的对其进行编码)

I wanted to know whether

  • A file encryption algorithm can be designed in such a way that it can perform the activities of a file compression as well (any live example?).
  • Also can I integrate it to a Mobile SMS Service, I mean for text messages?

Also I wanted to know about binary files...if a plain text file is encoded in binary does its size reduces? Also is it better to encode a plain text file to a binary one rather than encoding it to any other format (in case if anyone wants it to encode for any purpose)

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

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

发布评论

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

评论(3

意中人 2024-11-06 05:48:49

事实上,所有像样的加密程序(例如PGP)都会在加密之前压缩数据。他们使用 ZIP 等主流工具进行压缩。原因是一旦数据被加密,它看起来就像随机噪声并且变得不可压缩,因此只能在加密之前进行压缩。您可能无法对 SMS 执行此操作 - 您必须遵守 SMS 的规范,因此您最好检查这些规范。

In fact all decent encryption programs (take PGP for example) compress data before encryption. They use something mainstream like ZIP for compression. The reason is once data is encrypted it looks like random noise and becomes incompressible, so it can only be compressed before encryption. You likely can't do that for SMS - you have to obey the specifications for the SMS so you'd better check those specifications.

千柳 2024-11-06 05:48:49

压缩去除冗余信息。冗余信息使破解加密变得更容易。所以是的,加密和压缩是兼容的。我不知道是否有一种算法可以同时完成这两件事。

是的,二进制文件通常比纯文本文件小。例如,在文本中写出的数字 34(至少)需要 2 个字节,而在这 2 个字节中,您可以写入一个大至 65000 的数字。使

某种编码比另一种编码“更好”的原因在于它的用途。如果您要优化大小,二进制可能更好。如果您正在优化可读性或优雅的失败,文本可能会更好。

Compression removes redundant information. Redundant information makes breaking an encryption easier. So yes, encryption and compression are compatible. I don't know if there is an algorithm designed to do both things though.

Yes, a binary file will usually be smaller than a plain text file. For instance, the number 34 written out in text takes 2 bytes (at least) whereas in those same 2 bytes you could write a number as large as 65000.

What makes an encoding "better" than another is the purpose to which it is put. If you are optimizing for size, binary is probably better. If you are optimizing for readability or graceful failure, text might be better.

熟人话多 2024-11-06 05:48:49

第一个问题:没有理由说这是不可能的。由于您仍然可以加密压缩数据,反之亦然,因此您可以通过尝试来测试其好处。我不知道它是否可以用于短信,但如果有人想给出合理且合适的答案,您必须解释您要做什么。

第二个问题:纯文本仍然是二进制的,它只是可读并以某种字符集进行编码。主要区别在于纯文本通常符合某种编码,例如 UTF-8 或 ISO-8859-1。

您仍然可以压缩纯文本,这使其成为传统意义上的“二进制”,您只能看到奇怪的字节。 :-)

First question: No reason why it shouldn't be possible. Since you can still encrypt compressed data and vise versa, you can test the benefits by trying. I don't know if it can be used for text messaging, but you'd have to explain what you're trying to do if anyone wants to give a reasonable and fitting answer.

Second question: plain text is still binary, it's just readable and encoded in a certain character set. Main difference is that plain text usually conforms to a certain encoding, say UTF-8 or ISO-8859-1.

You can still compress plain text, which makes it "binary" in the traditional sense that you only see weird bytes. :-)

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