C# “即时”将字符串添加到加密的 zip 文件
我有这个问题:
我有一个应用程序收集一些需要存储在磁盘上的信息,但我不想让其他人如此轻松地查看/访问它(出于安全考虑,我不想将其存储在磁盘上)普通形式)。信息是纯文本字符串缓冲区,并且有时 - 当缓冲区达到大约时。 16kByte 我想将该缓冲区直接存储到加密的 zip(或任何其他存档)文件中。选项有: 1. 将新的~16kB文件添加到加密的zip中 2. 将缓冲区附加到加密 zip 中的现有文件
这可能吗?如果是这样,怎么办?任何帮助或链接如何做到这一点?
I have this problem:
I have an application which harvests some information which is necessary to be stored on disk but I don't want to other see/access it so easily (due the safety I don't want to store it on disk in plain form). Information is plain text Stringbuffer and from time to time - when buffer reaches approx. 16kByte I want to store that buffer directly into encrypted zip(or any other archive) file. Options are:
1. Add new ~16kB file to encrypted zip
2. Append buffer to existing file in encrypted zip
Is that possible? If so, how? Any help or link how to do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
真的需要使用 ZIP 吗?这绝对是可能的,但会使事情变得复杂。
首先,我会看看 CryptoStream,有几个关于如何使用它的示例,例如此处。这将允许您继续写入流,并让它担心实现细节。
Is it really a requirement to use ZIP? It is definitely possible to do, but complicates matters.
To start, I would have a look at CryptoStream, there are several examples out there on how to make use of it, e.g. here. This would allow you to keep writing to the stream, and let it worry about the implementation details.
不必担心存档以及可能需要使用第三方 DLL,为什么不直接使用 Rijndael 或 RSA 加密字符串并将其写入磁盘上的文件呢?
或者,您可以以纯文本形式编写它,但更改文件的权限,以便只有您的应用程序可以读取它。
Without having to worry about archives and potentially needing to use a third party DLL, why not just encrypt the string with Rijndael or RSA and write it to a file on disk?
Alternatively, you could write it in plain text but change the permissions on the file so that only your application can read it.