C# CF:动态文件加密/解密

发布于 2024-08-25 05:16:32 字数 239 浏览 5 评论 0原文

我看过很多关于文件加密/解密的文章,通常使用一个按钮来选择要加密的文件,使用另一个按钮来解密文件。

我见过一些像 truecrypt 这样的应用程序,可能还有其他应用程序,它们可以通过透明方式进行动态文件加密。这意味着当点击访问加密文件时,它将自动解密并播放/打开该文件。然后当文件关闭时,它将自动再次加密。

有人说检测文件打开的唯一方法是通过文件系统过滤器。

但是在 C# 紧凑框架中还有其他方法可以做到这一点吗?

i've seen many article on encrypt/decrypt of file and typically a button is used to choose the file for encrypt and another button to decrypt the file.

i've seen some application like truecrypt and probably others which does file encryption on-the-fly with transparent. this means that when a encrypted file is clicked to access, it will automatically decrypt and play/open the file. then when the file is closed, it will automatically encrypt again.

some have said that the only way to detect file open is through file system filter.

but is there other ways to do this in c# compact framework?

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

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

发布评论

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

评论(3

命硬 2024-09-01 05:16:32

您可以为所有加密文件指定一个特定的文件扩展名,该文件扩展名由解密程序处理,然后当用户打开该文件时,您的程序将解密它,然后在正确的应用程序中打开它。

You could give all the encrypted files a specific file extension which is handled by your decryption program, then when the user opens the file, your program would decrypt it and then open it in the correct application.

放肆 2024-09-01 05:16:32

我想我理解你的问题。您不控制显示文件的程序,您只想控制幕后文件的加密和解密,而程序甚至不知道它发生了(就像 .docx 文件,会在 Word 不知道的情况下进行加密和解密) 。我认为你应该研究一下 WMI。我没有专门使用它来检查与检索或保存文件有关的系统事件,但我已经使用它来挂钩系统事件并在某些时候非常有效地触发代码。以下是 MSDN 参考:

WMI 参考

我会调查 __Instance 事件。就像用于将文件保存事件到 IO 的 __InstanceModificationEvent 类一样:

__InstanceModificationEvent 参考

希望这能让您走上正轨!

I think I understand your question. You don't control the programs which display the files, you want to just control the encryption anddecryption of the files behind the scenes without the program knowing it even happened (like a .docx file, would be encrypted and decrypted without Word knowing it). I think you should look into WMI. I haven't specifically used it to check for system events having to do with files being retrieved or saved but I have used it to hook into system events and set off code at certain times very effectively. Here is the MSDN reference:

WMI Reference

I would look into the __Instance Events. Like the __InstanceModificationEvent class for file save events to the IO:

__InstanceModificationEvent Reference

Hope this get you onto the right track!

糖果控 2024-09-01 05:16:32

我在 MS Foums 中回答了这个问题。您必须编写一个文件系统过滤器并且过滤器只能用C编写。

I answered this in the MS Foums. You have to write a file system filter and that filter can only be written in C.

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