双向文件夹加密同步可保护我的 Dropbox 数据

发布于 2024-11-07 19:57:55 字数 886 浏览 0 评论 0原文

我想编写一个小的 .NET 脚本/工具,其功能至少与 SecretSync 或 < a href="http://www.boxcryptor.com/" rel="nofollow">BoxCryptor,但不将加密密钥存储在公司的 Web 服务器上。

首先,这听起来很简单:您有两个文件夹 - 一个“解密”文件夹和一个“加密”文件夹。在这两个文件夹上都有一个 FileSystemWatcher因此,当文件发生更改时,该工具会收到通知。 如果“解密”文件夹中的文件发生更改,它会加密该文件并将其写入“加密”文件夹。如果“加密”文件夹中的文件发生更改,它将解密该文件并将其写入“解密”文件夹。

到目前为止没有问题。

但是,如果用户直接从“解密”文件夹运行应用程序(例如 KeePass)会发生什么?同步和加密过程现在会遇到问题,因为文件已被应用程序锁定。 我可以采取一些措施来避免处理此问题,以便应用程序仍然可以在同步和加密过程旁边运行吗?

感谢您的帮助!

更新:我仍然找不到这个问题的答案。当使用 FileSystemWatcher 类进行同步时,很容易应用加密/解密,但您会遇到文件锁定问题(因为流或应用程序阻塞文件)。我还尝试了 Microsoft Sync Framework。文件同步可以使用它,但我不知道如何动态加密/解密文件。

也许有人有一些工作代码示例。

I'd like to write a little .NET script/tool which does at least mostly the same like SecretSync or BoxCryptor, but without storing the encryption key on a company's web servers.

First it sounds very simple: You have two folder - a "decryped"-folder and and "encrypted"-folder. On both folders there is an FileSystemWatcher so the tool gets notified when a file has changed.
If a file changes in the "decryped"-folder, it encrypts the file and writes it to the "encrypted"-folder. If a file changes in the "encrypted"-folder, it decrypts the file and writes it to the "decrypted"-folder.

No problem so far.

But what happens if the users runs a application (like KeePass for example) directly from the "decryped"-folder? The sync and encryption process will now run into problems because the files are locked from the application.
Is there someting i can do to avoid this problem handled, so the application can still run beside the sync and encryption process?

Thanks for any help!

Update: I still couldn't find a answer to this question. When using FileSystemWatcher-class for syncing it is easy to apply the encryption/decryption, but you are running into problems with file locks (because of the streams or applications blocking the files). I also tried Microsoft Sync Framework. File sync works with it, but i don't know how to encrypt/decrypt the files on the fly.

Maybe someone has a little working code sample.

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

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

发布评论

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

评论(4

多彩岁月 2024-11-14 19:57:56

受到 Ivanov 答案的启发,您也许应该看看 AlphaVSS。它是卷影复制服务的 .Net 包装器。

有了这个,您可以定期(例如每 15 分钟)创建一个快照,并将文件从 VSS 副本中的解密文件夹复制到加密文件夹中。为了提高速度,您仍然可以使用 FileSystemWatcher 来简单地记录自上次复制以来已更改的文件,并从卷影副本中仅复制这些文件。

Inspired by the answer of Ivanov you should maybe take a look into AlphaVSS. It is a .Net wrapper around the Volume Shadow Copy Service.

With this in hand you could make a snapshot in a regulary basis (like every 15 minutes) and copy the files instead from the decrypt folder out of the VSS copy into the encrypt folder. To increase the speed you could still use the FileSystemWatcher to simply log which files have been changed since the last copy and copy only these files from the shadow copy.

谜兔 2024-11-14 19:57:56

考虑使用卷影复制服务 ,确保您获得适合您选择的操作系统的 SDK

look into using Volume Shadow Copy Service, make sure you get the SDK for your OS of choise

找回味觉 2024-11-14 19:57:56

BoxCryptor 使用 Dokan 库,它是 Windows 用户模式文件系统。该库允许您的程序接收有关虚拟驱动器中各种文件系统相关操作的回调。这样您就可以响应这些回调并根据文件系统操作加密/解密数据。

BoxCryptor is using Dokan library which is a user mode file system for windows. The library allows your program to receive callback about various file system related operations in the virtual drive. This way you can respond to these callbacks and encrypt/decrypt data based on the file system operation.

幽蝶幻影 2024-11-14 19:57:56

文件系统过滤器驱动程序可能是实现您的任务的唯一正确方法。通过这种方式,您可以实现数据的动态加密、解密和镜像。

我相信我们的 CallbackFilter 会对您有所帮助。这是一个文件系统过滤器(包含驱动程序,您只需编写用户模式代码),它允许您检查和修改文件系统请求的内容。包含加密示例。

File System Filter driver is probably the only correct way to implement your task. This way you can implement on-the-fly encryption, decryption and mirroring of data.

I believe that our CallbackFilter will help you. This is a file system filter (driver is included, you write only user-mode code) which allows you inspect and modify contents of file system requests. Encryption sample is included.

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