简体   繁体   English

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

[英]Two-way folder sync with encryption to secure my Dropbox data

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. 我想编写一个.NET脚本/工具,它至少与SecretSyncBoxCryptor大致相同,但不会将加密密钥存储在公司的Web服务器上。

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. 在两个文件夹上都有一个FileSystemWatcher,因此当文件发生更改时,工具会收到通知。 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. 如果文件在“encrypted”文件夹中发生更改,它会解密文件并将其写入“已解密”文件夹。

No problem so far. 到目前为止没问题。

But what happens if the users runs a application (like KeePass for example) directly from the "decryped"-folder? 但是如果用户直接从“已解密”文件夹运行应用程序(例如KeePass )会发生什么? 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). 使用FileSystemWatcher-class进行同步时,很容易应用加密/解密,但是您遇到了文件锁的问题(因为流或应用程序阻塞了文件)。 I also tried Microsoft Sync Framework. 我也尝试过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. 也许某人有一些工作代码示例。

Inspired by the answer of Ivanov you should maybe take a look into AlphaVSS . 受到伊万诺夫答案的启发,你应该看看AlphaVSS It is a .Net wrapper around the Volume Shadow Copy Service. 它是卷影复制服务的.Net包装器。

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. 有了这个,您可以定期制作快照(每15分钟一次),然后将文件从VSS副本中的decrypt文件夹复制到encrypt文件夹中。 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. 为了提高速度,您仍然可以使用FileSystemWatcher简单地记录自上次复制以来哪些文件已更改,并仅从卷影副本中复制这些文件。

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

BoxCryptor is using Dokan library which is a user mode file system for windows. BoxCryptor正在使用Dokan库,这是一个用户模式文件系统。 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. 这样,您可以响应这些回调并根据文件系统操作加密/解密数据。

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. 我相信我们的CallbackFilter会帮助你。 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. 包括加密样本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM