meld-cp / obsidian-encrypt

Hide secrets in your Obsidian.md vault
MIT License
607 stars 36 forks source link

Re-encrypt notes automatically #31

Closed DJN0 closed 1 year ago

DJN0 commented 2 years ago

Would it be possible to re-encrypt a decrypted note automatically with the original password after a certain amount of time and/or on exit? I've found it a hassle to view and edit encrypted notes on a frequent basis, because I need to re-enter the original password twice every time I'm done working on an encrypted note (and it has to be twice so that I don't lose a note off of one mistyped password).

meld-cp commented 2 years ago

Hi @DJN0,

It may be possible to do something like that, but not cleanly with the current architecture of this plugin.

I may look into creating a new plugin for this workflow, I can see how it would be more convenient.

Alternatively, encrypting your whole vault with something like https://github.com/cryptomator/cryptomator may be a more reliable option.

mardoqueo commented 2 years ago

+1 on this. Promt for password on open, auto encrypt on close.

Might be tricky AF since how would it handle 'force quit' or obsidian crashing?

Toucani commented 2 years ago

+1 for this.

I wonder if Obsidian API actually allows the plugin to see any note. If it does, it seems just adding a thread with a timer to encrypt the note back would solve it. However, handling crashes, force quits, and kill -9 is indeed super tricky without any demon running on the host system...

Another though: maybe we could achieve the same result by a standalone, 3rd party app, that could decrypt an .md file, and auto encrypt it after some time, leaving Obsidian just as a viewer? However, this would require the app to be mobile-friendly to be able to encrypt/decrypt the notes on the phones...

Gewerd-Strauss commented 2 years ago

However, handling crashes, force quits, and kill -9 is indeed super tricky without any demon running on the host system...

Little food for thought that has not been mulled over too much so far: The crude solution to this is, when encrypting, to :

  1. Write an unencrypted copy besides the current note,
  2. Encrypt original version
  3. Ensure encryption is successful, checking if submitted password correctly decrypts
  4. if yes: delete backup
  5. if no: restore from backup

Of course you run into issues where you loose the security if the backup is synced to elsewhere before being deleted. I am not sure if that is possible to be prevented. It would be possible for normal sync by designating a folder into which you'd put the backup, and then set that folder up to not be synced. As for Github-sync/3rd-party syncing? No clue. Probably doable, but not natively supportable by the plugin itself probably ¯\(ツ)

I guess you could also just hold the copy in a variable while performing the encryption, and then just restore from that - which should resolve the issue above.

meld-cp commented 1 year ago

Please check version v2.0.0 and see how you get on with the new standalone encrypted note setup.

mardoqueo commented 1 year ago

It's amazing!!!! Thanks!

mardoqueo commented 1 year ago

Please check version v2.0.0 and see how you get on with the new standalone encrypted note setup.

OK honeymoon's over. Can we have Markdown inside encrypted note? 🙏🙏🙏 pretty pretty pretty please?