For those interested, waiting for Scrivener to find time and resources to create a method to apply a password to the project, I have created two scripts that generate and edit a full project directory encrypt all via openssl.
First of all you need to initialize the encryption project:
- Create a directory where you project will stay;
- move to that directory;
- run Scrivener and create an empty project then save it with the same name of the directory and then close Scrivener;
- run che CreateProject script.
Here the code of the CreateProject script;
#!/bin/bash
CurDir="$(pwd)"
ProjName=$(basename "`pwd`")
cd /tmp
echo 'Creating file for ' $ProjName '...'
read -p "Press [Enter] to continue or [CRTL-C] to interrupt process..."
mkdir "$ProjName"
mv "$CurDir"/"$ProjName".scriv "$ProjName"/
tar cf "$ProjName.tar" "$ProjName"
openssl des3 -salt -in "$ProjName".tar -out "$CurDir"/"$ProjName".tar.encrypt
echo -e "\n\nSecure erasing all clear text files and directories...."
bcwipe -md -fI "$ProjName".tar &&
bcwipe -md -rfI "$ProjName"/
#echo -e "\n\nAll clear text files and directories safely destroied...!!\n"
cd "$CurDir"
echo -e "\n\nEncrypted project "$ProjName" generated and ready to be used via EditProject."
Once created the encrypted project, every time you need to work on it do these operations:
- Move to the direcotory containing your encrypted project;
- Run the EditProject script… it will decrypt, untar, and open the project and standby waiting an [Enter] to be pressed in the terminal window;
- Move to the opened project and do your whatever you have to do in the project;
- Once finished close Scrivener (it is the surest way to be sure that the modified project has been saved before re-encrypting;
- Go back to the terminal windows and press [Enter]
and that’s it!
Here the code of the EditProject script;
#!/bin/bash
CurDir=$(pwd)
ProjName=$(basename "`pwd`")
cd /tmp
openssl des3 -d -salt -in "$CurDir"/"$ProjName".tar.encrypt -out "$ProjName".tar &&
tar pxf "$ProjName".tar &&
open /tmp/"$ProjName"/"$ProjName".scriv
read -p "Press [Enter] to continue after your editing job..."
tar cf "$ProjName".tar "$ProjName"/ &&
openssl des3 -salt -in "$ProjName".tar -out "$CurDir"/"$ProjName".tar.encrypt &&
echo -e "\n\nSecure erasing all clear text files and directories...."
bcwipe -md -fI "$ProjName".tar &&
bcwipe -md -rfI "$ProjName"/
echo -e "\n\nAll clear text files and directories securelly destroied !!\n"
The script EditProject must be run from the directory where the encrypt project is saved. All operations as, decrypting, untaring, running Scriver, saving and closing the project and rencrypting will be done in /tmp. The final encrypted file, result of your editind process, will be stored again in the directory from where it was initially read,
Notes:
- For secure erasing I use bcwipe if you prefere simply deleting the files in the normal way change the lines
bcwipe -md -fI "$ProjName".tar &&
bcwipe -md -rfI "$ProjName"/
with
rm "$ProjName".tar &&
rm -r "$ProjName"/
-
copy and past the scripts, once per file, and set them executable via chmod u+x ScriptName. The script can be in any executable directory reachable from the user.
-
You can also put a copy of the EditProject scritp into the folder containing the encrypted file.
-
if you want to run the EdiProject script via Finder remeber tha you must add .command suffix to the script name or Finder will not execute it. So the script name will be EditProject.command
Obviously, these two scripts can be used to protect anything: it is enough that what you want to open, can be opened via the open command via terminal.
Good writing!!