How to encrypt and password protect a file/folder on Mac?

This question came up at work the other day, and I did not know the answer to it. Now I do ;). Here are the steps to do it.

First we create a few files to work with. The files are empty but that does not matter for now:

touch file1.txt
touch file2.txt
touch file3.txt

Then we will execute the following command to zip them and put a password:

zip -er fileszipped.zip file1.txt file2.txt file3.txt

First you will be asked to enter a password and you have to confirm it. Then it adds/update the file in the zip called fileszipped.zip

kristofvandenborn@Kristofs-MacBook-Pro-2 ~ % zip -er fileszipped.zip file1.txt file2.txt file3.txt
Enter password: 
Verify password: 
updating: file1.txt (stored 0%)
updating: file2.txt (stored 0%)
updating: file3.txt (stored 0%)

Now, the proof of the pudding is in the eating someone said once. So let’s try to unzip and see if we get asked for a password.

kristofvandenborn@Kristofs-MacBook-Pro-2 ~ % unzip fileszipped.zip
Archive:  fileszipped.zip
[fileszipped.zip] file1.txt password: 
 extracting: file1.txt               
 extracting: file2.txt               
 extracting: file3.txt     

And sure enough we get asked for a password as well when we try to unzip.

Categories

Latest articles

Latest comments

No comments to show.

All Splunk Posts