There are not very many ways to encrypt files on your Mac. However, if a neat Terminal solution you can encrypt any file with a password. We are going to use a Terminal command called OpenSSL. Its a program designed to create the https bits of website through secure certificates. We are going to use it encrypt files instead. There is one caveat to this command in that it will only encrypt text files. However, this is only a minor problem we can work around.
Encrypting Files With A Password
To encrypt a file, in this case a text file, open Terminal located in your applications utilities folder.
Navigate the to directory where the file is located. Since you start in the user drive typing
cd desktop will take you to your desktop.
We can now encrypt our file for these type the following (it helps to set up the command within textedit first):
openssl enc -aes-256-cbc -e -in textfile.txt -out encrypted.txt -pass pass:mactricksandtips
Openssl is the command we are using, followed by the encrypt modifier. In this instance we are going to use a secure aes 256 bit encryption.
The next half of the command, -in textfile.txt, is the text file we are going to convert. It will then be converted using the, -out encrypted.txt, option to a second text file.
The password option is supplied with -pass pass:mactricksandtips. You can change the mactricksandtips bit to anything you want.
Once you have hit enter, the file will be encrypted. If you don’t know the password it will be hard to decrypt.
Decrypting Files With A Password
To decrypt the file you run the same command but in reverse.
openssl enc -aes-256-cbc -d -in encrypted.txt -out 2.txt -pass pass:mactricksandtips
This is in decryption mode and will decrypt the file using the password.
If you get the password wrong it will be be able to decrypt the file.
Encrypting Zip, Images And Other Files
If you want to encrypt other file such as images, or zip files you can use this trick. However you have to put in one step before you go into Terminal. The openssl command will only accept text files.
Within Finder change the file extension from .zip, .png, .jpg to .txt. Finder will convert the file to a text one (it doesn’t really do anything). Now when you use the command it will run and encrypt the file. You just have to remember when you decrypt the file to change it back to the original format.
This command is a little tricky to use. You have to remember both the encryption method used and the password, however once you have that you can encrypt anything.