Encryption Desired

Feature request?

Is there a way to build an action in Drafts to mimic encryption in Evernote?

In Evernote, I can encript a word, phrase, or passage.

Hilight the words, encript them, and assign a password, The encripted text in marked in the note and grayed out. Put in your unique password and see the words/numbers.

4 Likes

Seems like it should be possible to implement this as an action via JavaScript? Even better if was built-in though…

I’d like an action which would encrypt the text. What I do now is to copy the text and paste into Paranoia Text Encryption PTE - get it encrypted and go back to Drafts to paste over the top.

+1 for me on having some kind of built-in encryption of a single draft. Ideally unlocking with touch/Face ID.

Or if simple to do an option to not show the preview body text of a draft in the Draft List. Maybe masking drafts with a particular tag. Sometimes when using screen sharing tools they switch to the space I have Drafts in, briefly showing my drafts. Or to avoid sensitive info being visible to a passerby.

Thanks.

In case it is of use, I’ve added some encryption-related functionality into TADpoLe. This utilises crypto-js, a version of which now gets downloaded when you refresh to the latest version of the library from the ThoughtAsylum action group*

To go along with this, there are numerous encryption actions all based around the use of AES that I’ve added to the ThoughtAsylum action group suite. These include some functionality around personal key (/passphrase) generation based on truly random hexadecimal strings from random.org.

For example, the ThoughtAsylum - Power User action group includes an action *TAD-AES Encrypt Draft` (in the AES section of the group) which will allow you to enter your own key or generate one for you (which is then placed on the clipboard. The draft is then encrypted. but please note that previous revisions and backups are likely to include your original decrypted content, so do keep that in mind as you encrypt/decrypt drafts.

2020-12-31-21.23.33

There is of course a TAD-AES Decrypt Draft action in the same action group to reveres the process. These are use at your own risk, so before using in earnest do satisfy yourself that it works reliably. As I noted above, this is directly utilising crypto-js, so it should be solid.

There are also actions for encrypting/decrypting text selections and the clipboard.

If you want something that’s not as secure but easier to use that does not involve remembering keys, but is enough to keep a casual observer from snooping, then the Corrupt Content section of the ThoughtAsylum - Power User action group includes the following:

TAD-ROT13 Encode Draft - rotates the alphabet through 13 places, so running a second time restores to the original version.

TAD-Obfuscate Draft/TAD-Deobfuscate Draft - runs AES encryption/decryption utilising the draft’s own UUID as the key.

Maybe these will be useful to folks for keeping prying eyes off their drafts? Enjoy!


* The easiest way to refresh is to run the TAD-Setup/Refresh action in the core ThoughtAsylum action group.

1 Like

Thanks Stephen, the Obfuscate actions will do the job for me most of the time. Only needing the full encryption much less frequently.

Trying to use Obfuscate I get an error.
Script Error: Error: The file “crypto-js.js” couldn’t be opened because there is no such file.
Line number: 9164, Column 9

I have done a TAD Refresh. Is there another action/install I need for crypto? If it matters this is on an iPad.

The 9164 line is the require line that indicates it is looking for the library file in the Scripts directory for Drafts.

require(tadLib.cryptoLibName + ".js");

In the TAD-Setup/Refresh action’s script step (the only step), there are some lines that set up some information about the crypt library.

const CRYPTO_URL = "https://tadpole.thoughtasylum.com/assets/library/crypto-js.js";
const CRYPTO_NAME = "crypto-js";

That first line specifies the URL where you can download the file.

Can you check that these lines are in the action and that you are therefore running the refresh action from the right version of the action group?

Towards the end of the code there’ a line that makes a call to download the file.

objHTTP.TA_updateCryptoLibrary();

This utilises the following function which uses the same code as the tad and beautifier libraries

// Save a copy of the minified crypto-js library file to the Drafts library scripts folder.
HTTP.prototype.TA_updateCryptoLibrary = function()
{
	return this.TA_downloadLibrary(CRYPTO_URL, CRYPTO_NAME);
}

That hasn't changed in months and I can see the crypto file at the URL specified.

Everything I can see indicates that it should be copying it down into the folder.

But, I have a few suggestions you can try:

1. Local Refresh

If you have refreshed on a different device, sometimes, but certainly not every time, iCloud sync gets lazy and does not keep things in sync as much as it should. I’ve had it open a few times with files in the Drafts folder structure when I’ve been testing across devices. To rectify that, you can run the refresh on any device any time and it should force a refresh of the local copy; which should then propagate out to other devices vi iCloud sync.

Give the obfuscate action a try again.

2. Check the File and Open It

Another iCloud issue is that sometimes the files it has are really just placeholders. I’ve only seen it as part of the sync issue above, but, there may be other occasions on which it occurs.

If you navigate to the scripts folder in iCloud, and open the file in an app to view it, that forces iCloud to get a copy from cloud storage if it has not already done so.

Give the obfuscate action a try again.

3. Manually Copy the File

If the file isn’t being copied I would like to understand why, but we can manually put the file in place. Copy the file content from https://tadpole.thoughtasylum.com/assets/library/crypto-js.js and paste them into a new file in your Drafts Scripts folder called crypto-js.js.

Give the obfuscate action a try again.

Hopefully something like that will help, but if this fundamentally isn’t an iCloud sync issue, I would like to get to the bottom of what’ going on. The download functionality is common to all of the library files the refresh action retrieves and they are all stored in the same directory on GitHub, so I’m struggling to think of why it wouldn’t be getting copied or the refresh action is out of date even though the rest of the action groups are in date unless you haven’t updated the core action group and thus the refresh action.

Hope that helps, and do let me know how you get on.

I had an old TAD Setup. I (maybe) wrongly thought TAD Setup refreshed when running it. I deleted the group and installed again, ran Refresh and this time I see it downloaded crypto.

It is working beautifully now. :slightly_smiling_face:

Thanks Stephen.

Great, glad it was a simple one to track down. :slight_smile:

The set-up action doesn’t get updated very often. I think this is only the second time I’ve had to do it, but it may occur again in the future.

In case you ever have need for it in the future, there is a change log for the action group, and I’ll also be making use of a new feature Greg has in beta at the moment to help highlight changes on the action directory too.

Sorry for hijacking this thread, but is there an action somewhere that will pull random words from a diceware list to generate a password? That’s would be a hugely helpful thing for my workflow.

I have recently being playing around with the ThoughtAsylum action group. What an epic effort! @sylumer, good work.

1 Like

Maybe something like this?

Of course, I’ll add the caveat that I’m not convinced that the random number generator Drafts accesses is truly random enough to make this a meet the Diceware requirement for a truly random number generator.

I’ll leave it as an exercise for you how you could swap to a better random number generator. For example, TADpoLe’s ta_randominteger function.


By the way, why did this necessitated a thread hijack? New topics are for new questions, and this doesn’t seem to actually relate to draft encryption at all and seems to be a different question on a different topic.

Merely because I stumbled upon this thread whilst search for my question. It seemed to fit in with the general conversation- especially as I was thinking of it with regards to your action group and that was mentioned during the thread. I’m pretty new to these particular forums so forgive my lack of knowledge of how they work and the correct décorum.

Thank you for your insight though. Obviously the best way to create truly random word generation is to use actual dice - and I do for important passwords. But I use drafts (in this way at least) in relation to my clients - I create their client number here, store all of their info until I have finished with them and send them to my obsidian database. Part of the things I need to generate for them is a password for their online gallery (I’m a photographer). From experience diceware (6 words) is better as they can easily read and/or remember those whilst still remaining secure. Plus I’m a great fan of the method. In this case whilst they need to be secure, part of the reason dice are used to choose words is to eliminate obvious strings via human associations, which if I just made them up I would be contributing to. I think whatever method that could be devised here would be random enough for my purposes.

1 Like

Is there a way that I can change the diceware list which is used in the example you have created?

Yes, just edit the action and modify the list.

I just took the one that appears to be the standard, but there is nothing stopping you from using any such list you like. Just convert it into JSON and replace it in the first step in the action, to set the variable that holds the list.

Ok thank you - it was the json bit I didn’t realise that that was what it was.