Two Ways To Password-Protect Files On Your Mac

If you need to encrypt some files so the only way to acess them would be with a password, you can use one of two methods. By using Disk Utility you can create read/write disk images that can be opened on any Mac. But if you need to send some files to another person, you may want to instead use the Terminal to create an encrypted ZIP achive that will work on Windows as well.
You can also watch this video at YouTube.
Watch more videos about related subjects: Security (133 videos).

Video Transcript

Hi, this is Gary with MacMost.com. Let me show you two ways that you can encrypt files so no-one can get to them without a password.
Ever wonder why there are no ads at the MacMost.com website. Well that's because MacMost is supported by a great group of supporters. You can go to MacMost.com/patreon. There you can read more about it, join us, and also get exclusive content.
So let's say you want to keep some files on your Mac protected so nobody can get into them without entering a password. Now there are ways to do that specifically with Pages, Numbers, and Keynote documents. Even word documents and such. But if you just wanted to put a bunch of files in a folder and then password protect it there are two ways that you can do. One way is to use Disk Utility and create a Mac disk image and encrypt that. Another way to do it is to create a Zip file using the Terminal with a password. This will work great if you need to then send those files to somebody that may not be using a Mac.
So I've got a folder here. It's about 12 megs in size. Say  I want to encrypt all of the contents so you can only get to them with a password. Let's start by using Disk Utility. Now Disk Utility is already on your Mac. It's in your Applications folder inside the Utilities folder. I'm going to launch it with Spotlight. So Command space and Disk Utility and run it. Now Disk Utility looks different in different versions of macOS so yours might look a little different. This is macOS Mojave. It's going to give me two options to create a disk image and this disk image is going to act like a regular file when I'm not using it. So just any old file.
When I try to open it it's going to mount itself just like it's an external hard drive. So it looks like I've attached say a USB flash drive to my Mac. To create on you can go to File, New Image, and there are two options. The first option is to create a blank image. So you're creating the disk image here with nothing in it and then you can add the files to it later. If you choose this you get a ton of different options. You get to pick a file name and also a name for what the disk is called once it's mounted. You get to pick a size. This is where it gets tricky because you need to know the size. Here I said this was 12 megs so maybe I want to create one that's 20 megs. You can choose a Format. You can choose the new APFS format or the old one for older Mac compatibility. You can then set encryption. 128 is fine for just about everybody. If you work for the CIA or MI6 then you probably would want to use 256. Now I've showed you all this but this is not what we're going to use because there is an easier way.
You can go to File, New Image and say Image from Folder. Here you can select the folder. Let's go to the Documents folder here. Here's that Project A that I was talking about and let's choose it. Now it's going to ask a bunch of things. It's going to want to Save the file as something. It's going to choose the same name as the folder. Okay. Then where to save it. Let's save it to the Desktop just so I could see it appear up here. Encryption, we want to turn that on. Now we set the password and verify. If you forget this password you can never get into this thing, ever. So make sure you remember it.
Then you choose the format. Now if you choose Read Only or Compressed you'll never be able to change the files in here again. You could open it up. You could read them and you can Copy them out which may be all you need. But you won't be able to make a change and save it. Compressed, of course, is great because it will not only save this as a disk image but also use some compression. So maybe instead of 12 megs I'll end up with something less for the final file. Read Write though let's you change the files. So, if say you're putting a list on there, like an Excel or Numbers document that's got a list of all the books you own, and every once in awhile you want to open this thing up and make a change, then Read Write is what you want. 
Now let's Save this and it's going to create it and put those files in it and it will put it where we asked which was on the Desktop. Then it'll say Done. Now I can hide Disk Utility there and I can see what I've got here. If I were to double click this to open it what will happen is it's going to mount it. It's going to ask me for my password. I'll type the password. Notice the little checkbox here. This is really useful. If you check this you'll never have to enter the password on your Mac again. It seems to kind of defeat the purpose and it does for some uses. But let's say you're going to be sending this file to somebody by mail or sharing it online somehow and you want them to be able to enter the password in but you don't want to have to bother with it here on your Mac. Then checking that box makes sense. Otherwise leave it unchecked.
When you hit Okay you'll see it appear here under Location.  It mounts just like it's an external drive. I select it and I see all the stuff in there. It's a copy of what was in that folder. Now if I go back to Disk Utility here I can see it actually is listed under Drives. Here's my internal drive. I've got an external drive and Time Machine external as well. Here I have the disk image for what I've created. If I select it there I'll see used 12 megs. Free 11 megs. It's going to give me some extra free space. It didn't just make this thing just the perfect size. It threw a bunch of extra space. It seems to do about 10 megs extra space each time. This is so I can make some changes. Maybe add a file. Maybe edit one and there's room. Without that being a Read Write disk really doesn't make sense.
Now to kind of close it out and password protect it again you've got to Eject it. So you have a little Eject button here in the sidebar on Finder. You hit that and it's going to close the window because that is what it was showing. But if I open a new Finder window I'll see it is no longer listed there under Locations. The only way to get to those files again is to double click the disk image there and open it up entering the password. Now notice that the original folder is still there and it still has all those files in it. So if my intent was to password protect these I now want to delete these and empty the Trash.
Now these disk images are a Mac thing so somebody is going to need a Mac to open these up. If your goal here is to be able to encrypt some files and send them to someone they may not have a Mac. One of the most common reasons you need to do this is to encrypt some files and to send them by email because email is very insecure. So sometimes you want to encrypt files before you send them out to the internet to bounce from server to server until they get to the recipient. 
There is a completely cross platform way to do this and it's using the Zip utility in Terminal to create an encrypted Zip archive. Now you can create a Zip archive pretty easily but unfortunately you can't password protect it. I can do Control and then Compress and that creates a Zip archive. There's also utility for doing that here on your Mac as well. That won't create a password protected archive either. But you can use Terminal to do it. This is actually a pretty easy command in Terminal so if you're not comfortable with Terminal you still might be able to do this. Let me show you.
Terminal is also an app you already have on your Mac. To get to it you can do Command Space and then type Terminal and then launch it that way. The first thing you want to do is you want to go to the area where these files are located. So you want to go to your Documents folder. An easy way to do that is to do cd for change directory and then a space and then you can drag the icon from the folder here into the Terminal window. It will put the path in there. So you don't have to type all that and figure out what that was. Hit Return. Now you're there. I can actually do ls for list files and I can see there is Project A. So I'm in the right place.
Now I want to use the Zip command to zip up that folder. Zip command needs two special parameters. One is e and the other is r. You put a dash in front of them like that so 
-er. e means it's going to be encrypted and r means it's going to include everything in the folder. If there are folders inside of that folder it's going to go down into those as well. So it's going to act kind of like you would expect. Without r it wouldn't include things inside subfolders. 
Now you want to put two things here. You want to put the name of this archive that you're creating. So let's create something with a similar name to the folder. I'll do ProjectA, without a space, dot zip. Okay so that's the file name we're going to create. Now we need to give the name of the folder. Since there's a space in the file name we want to make sure we put it in quotes else the Terminal doesn't understand what to do with the space. So we'll do "Project A" like that. Now it's going to encrypt an entire folder into a file called ProjectA.zip and this is the folder it's going to encrypt. I'll hit Return. It's going to ask for that password. So I'll type it just like before and verify it just like before. You can see it runs through what it's doing. You can see it stored all the different files that are in there.
Now if I look at my Documents folder I can see in here that there is that ProjectA.zip file. Now the good news is you don't need to use Terminal to open this up. So I could delete Project A, the folder, and then later on when I go back to this what will happen is when I double click it it's going to prompt me for the password. What it's going to do when I enter it is not open it up like a disk image but actually create a new folder. It actually puts the number two after there because there already was a Project A folder. But all the files are in there just as before. So it pulls everything out and puts it in a new location. There isn't kind of the rewrite thing you get with Disk Utility. But this is very handy from being able to send this file in email in a protected zip file and then telling the person, not in the email but maybe over the phone or in person, what the password is. It's a great way to make sure those documents get from point A to point B without anybody being able to open them up.

Comments: 8 Comments

    Mark Freemantle
    6 years ago

    If you use the option to "Remember my password in my keychain" you may find it easy to Forget the password, because you can now open it (on this Mac) without needed to remember the password. So, I suggest immediately creating a TEXT file in that folder that saves the Password! If you email the folder they cannot see the TEXT file, but when they tell you "Hey, what's the Password?", you can re-open the folder (on your Mac), open the file, and tell them - but verbally, don't email it! ;-)

    6 years ago

    Mark: There's no need to save your passwords that way. You can just view them in Safari (or Keychain Access) when you need them. They are encrypted in there.

    Bob Gerard
    6 years ago

    Great video. Knew about the .dmg file; not about how to encrypt a .zip file.
    I am tutoring some seniors, folks in their 70's and 80's and trying to get them to securely store their passwords. Both your methods would be beyond their abilities, even with me walking them, slowly, through every step.
    OTOH, creating a Note in Note.apps, from what I could find online, IF they chose a very strong password is almost as good a method as the methods you suggest in your video? You agree/disagree?.

    6 years ago

    Bob: For passwords I would just use the built-in function in Safari (Keychain).

    george
    6 years ago

    Hi Gary can you erase those password-protected files in the future to save space?And how to do it?Thanks

    6 years ago

    George: You can delete those files just like any other file you create.

    Gene H
    6 years ago

    Gary, how do you delete the disk image, is dragging to the trash from the Finder left hand window ok?

    6 years ago

    Gene: You can delete it like any other file, by putting it in the trash.

Comments are closed for this post.