I wanted a way to quickly encrypt and decrypt text files in VSCode using a memorised pass phrase so I created an easy to use plugin to encrypt text in Visual Studio Code.
VSC has become the text editor of choice for most developers and it is relatively simple to create and publish a plugin using Javascript or Typescript.
The Encryption-VScode plugin uses AES encryption to encrypt/decrypt the contents of the current text file.
The Crypto-JS plugin is the only dependancy which gives access to the encryption module as crypto.subtle is not available within node.
It’s easy to install and use.
Instructions
Go to “File > Preferences > Extensions” and search Encryption-VScode then install and restart the editor.
When you want to encrypt a file press CTRL + SHIFT + P to open the command prompt and type “Encrypt”. You’ll be prompted to enter a pass phrase and the current text document will turn into an encrypted text string.
To decrypt open the command prompt and type “Decrypt”.
It’s a good way to store private information on a local device and could be useful for cold storage solutions as well. I did consider adding a salt in the settings.json but this would make it incompatible with other AES products/services.
The workflow is you write a document that you want to keep secure. Before saving it you encrypt the text and then save to a local hard drive. The encrypted document can then be safely saved and stored on the local device. When you need the data simply open up the text file and decrypt it using the plugin and passcode. The document can then be edited and modified before encrypting again and saving any modifications.
Software is provided as is with no warranty or guarantees. Source code is on Github at: https://github.com/jamesbachini/Encryption-VScode
The plugin is also available from Microsofts plugin market place: https://marketplace.visualstudio.com/items?itemName=JamesBachini.encryption-vscode
I’ve used this to secure documents on a local device where I don’t want sensitive data stored as plain text on the hard drive. Remember that the encryption is only as good as the passcode so use a strong and long alphanumeric phrase.
Currently as of July 2020 this plugin has over 900 downloads. I had one issue raised on Github which recommended cutting the line length for encrypted files to the default setting in vscode. This makes it easier to email encrypted documents.
Do not lose your passcode as there is absolutely no way to restore the file without it.