我应该采用哪种压缩/加密?
我们开发了一项服务,用于发送电子邮件……这一步非常简单。
下一步是:处理退回邮件。
为了实现这一点,我需要在标题中添加一些信息......假设这是一个简单的字符串(以使问题保持基本)。
当我正在寻找一种内部包含校验和的算法时(我不想创建 CRC 或类似内容并将其添加到标头中),我应该采用哪种压缩/加密(首选.net内置)-因此,更改加密/压缩字符串的某些字符并不意味着它是有效的!
这不一定是“高度复杂”的算法,因为我只想对更改/注入进行基本检测......
只是要明确:必须有机会解压缩/解密!
We've developed a service, which sends e-mails... quite trivial at this step.
The next step will be: handling the bounces.
To implement this I need to add some information into the headers... Let's say it's a simple string (to keep the question really basic).
Which compression/encryption (.net-built-in prefered) should I take, when I'm looking for an algorithm which includes a checksum internally (I do not want to create a CRC or alikes and add it to the headers either) - so, changing some char of the encrypted/compressed string doesn't mean it's valid!
This need not be a "high-sofisticated" algorithm, as I just want a basic detection against changes/injections...
Just to be clear: There must be a chance to decompress/decrypt!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您需要解压缩/解密消息,您可能需要双向加密。我不是这方面的专家,但我认为 .NET 内置了对 AES 的支持,这是一种 Rijndael 算法。您可以获取更多信息
If you need to decompress/decrypt the message, you probably want a two-way encryption. I am not an expert here, but I think .NET comes with built-in support for AES, which is a Rijndael algorithm. You can get more information here.
您考虑过/读过 OpenPGP 吗? 这个所以线程对您来说可能是一个很好的起点。
Have you thought/read about OpenPGP? This SO thread might be a good starting point for you.
要回答其中的压缩部分,您可能需要考虑使用 System.IO. Compression.GZipStream 或 System.IO. Compression.DeflateStream 类进行压缩。 DeflateStream 使用 LZW 压缩(带有一点黑客技术),与 ZLib 兼容(http://stackoverflow.com/questions/70347/zlib-complete-compression-streams)。
To answer the compression part of it, you may want to consider either the System.IO.Compression.GZipStream or System.IO.Compression.DeflateStream classes for compression. DeflateStream uses LZW compression that is (with a bit of hackery), compatible with ZLib (http://stackoverflow.com/questions/70347/zlib-compatible-compression-streams).