Security

How to Encrypt a Folder on Windows and Mac

To encrypt a folder on Windows, right-click it, choose Properties, then Advanced, tick "Encrypt contents to secure data" and click OK. On a Mac, use Disk Utility (File, New Image, Image from Folder) and pick an option in the Encryption menu to wrap the folder in a password-protected disk image.

The two systems work differently. Windows encrypts the folder in place and ties the key to your user account. macOS builds a new encrypted container file from the folder, which opens only with a password you choose. Both methods are covered below, plus a command-line version for each and a note on whole-disk encryption.

How to encrypt a folder in Windows 10 and 11

This uses the Encrypting File System (EFS). Per Microsoft, it is not available in Windows Home edition. It also needs the folder to be on an NTFS volume.

  1. Right-click the folder and select Properties.
  2. Select Advanced.
  3. Tick Encrypt contents to secure data.
  4. Select OK, then Apply, then OK.

If the box is greyed out or missing, you are on Windows Home, or the folder is on a drive that is not NTFS (a FAT32 or exFAT USB stick, for example). Once the folder is marked, files you add later are encrypted automatically.

Encrypt a folder from the command line with cipher

The built-in cipher command does the same thing. Microsoft's reference describes /e as encrypting the specified files or directories, and notes that directories are marked so files added afterward will be encrypted too.

cipher /e /s:"C:\Users\alex\Documents\Private"

/s:<directory> applies the operation to all subdirectories as well. To check the state of the current folder, run cipher with no parameters. Encrypted items are marked with an E and unencrypted ones with a U. Example output:

Listing C:\Users\alex\Documents\
New files added to this directory will not be encrypted.
E Private
U notes.txt

To undo it, run cipher /d /s:"C:\Users\alex\Documents\Private". The /d switch decrypts the specified files or directories.

Back up your EFS key before you rely on it

EFS keys belong to your account. If Windows is reinstalled, or your profile is deleted or damaged, the files cannot be opened without the original certificate and private key. Export them now:

cipher /x "C:\backup\efs-key"

Per the cipher reference, /x backs up the EFS certificate and keys to the file name you give. Store the exported file, and any password you protect it with, somewhere other than the same PC, such as an offline drive or a password manager. Without a backup, losing the account means losing the data.

Microsoft also documents what EFS cannot encrypt: compressed files, system files, system directories and root directories. A related warning in the cipher reference is that if a parent directory is not encrypted, an encrypted file could become decrypted when it is modified. That is why you should encrypt the folder, not just individual files in it.

How to encrypt a folder on a Mac

macOS has no per-folder encryption switch. The built-in way is an encrypted disk image: a single .dmg file that holds a copy of the folder and asks for a password when you open it.

  1. Open Disk Utility (search for it in Spotlight).
  2. Choose File, then New Image, then Image from Folder.
  3. Select the folder and click Open.
  4. Enter a file name and choose where to save it.
  5. Pick an option from the Encryption pop-up menu and enter a password when prompted.
  6. Pick an Image Format. "Read-only" cannot be changed after creation. "Read/write" lets you add and edit files later.
  7. Click Save, then Done.

The menu labels can differ slightly between macOS versions, and the encryption choices are listed in the pop-up itself. To use the contents later, double-click the .dmg, enter the password, and the volume mounts on your desktop. Eject it when you finish.

The image is a copy. Delete the original unencrypted folder only after you have opened the image and confirmed the files are inside. Deleting a file normally does not guarantee it cannot be recovered from the disk, so treat the old folder as still readable until you have dealt with it.

The Terminal version

The hdiutil tool does the same job. -srcfolder copies the folder contents into a new image, and -encryption turns encryption on. The manual page says the default algorithm is AES in CBC mode with a 128-bit key. You can request AES-256 explicitly:

hdiutil create -encryption AES-256 -srcfolder ~/Documents/Private -volname Private ~/Documents/Private.dmg

With a terminal attached, hdiutil reads the passphrase with readpassphrase(3), so it asks you to type one. The -stdinpass option reads it from standard input instead, which is useful in scripts but leaves the passphrase in your shell's hands, so avoid it for anything sensitive. The default image format when a source folder is given is UDZO, a compressed read-only image.

Which method protects against what

MethodWhere the key livesProtects againstLimits
Windows EFSYour Windows accountOther accounts on the PC, and someone reading the disk elsewhere without your accountNot on Windows Home. NTFS only. Files are open to anything running as you.
macOS encrypted disk imageA password you chooseAnyone who gets the .dmg file without the passwordIt is a copy. Forgotten password means no access.
Encrypted archive (7z, ZIP with AES)A password you chooseAnyone who gets the fileWorks on every OS, including Windows Home. Needs extracting to edit.
BitLockerTPM, PIN, or recovery keyA lost or stolen deviceEncrypts a whole volume, not one folder.

Folder encryption or whole-disk encryption?

Microsoft describes BitLocker as a feature that provides encryption for entire volumes, aimed at data theft or exposure from lost, stolen or decommissioned devices. It is available in Windows Pro, Enterprise and Education, and device encryption can turn it on automatically on qualifying hardware. If your concern is a laptop being lost, encrypting the whole drive is the stronger answer, because it also covers temporary files, the page file and every other location where copies of your data might land.

Folder encryption suits a narrower case: one set of files that should stay unreadable to other accounts, or one file you need to send or store somewhere you do not control. For that last case, a portable format that does not depend on a particular operating system is easier to share. See how to encrypt a file with GPG for a method that works on Windows, macOS and Linux.

Common problems

  • The Encrypt option is greyed out on Windows. Check the edition (Settings, System, About). Windows Home cannot use EFS. Also check the drive's file system in the drive's Properties; it must be NTFS.
  • Copying an encrypted folder to a USB stick. EFS works only on NTFS volumes, so a FAT32 or exFAT stick cannot keep the encryption. For portable copies, use an encrypted archive or GPG instead of EFS.
  • Another user cannot open the files. That is the intended behaviour. Their account does not hold your key. The cipher reference documents /adduser for authorising another user's certificate.
  • The disk image will not open on the Mac. The password is the only way in. There is no reset option.

Frequently asked questions

Can I encrypt a folder in Windows 11 Home?
Not with the built-in folder option. Microsoft's guide states that file and folder encryption (EFS) is not available in Windows Home edition. On Home, put the files in an encrypted archive such as a password-protected 7z or ZIP, or use a third-party encryption tool.
Does encrypting a folder with EFS protect it from other people who use my PC?
It protects the files from other Windows accounts, because only the account that encrypted them (and any added users or recovery agents) holds the key. It does not protect them from you being signed in: once you are logged in, the files open normally for anything running as your account.
What happens if I forget the password of an encrypted disk image on a Mac?
You cannot open it. Apple's documentation says that if you forget the password, you won't be able to open the disk image and view any of the files. Keep the password in a password manager.
Is encrypting a folder the same as password-protecting it?
No. Windows has no built-in way to put a separate password on a plain folder. EFS ties encryption to your Windows account. A macOS encrypted disk image does use its own password. An encrypted archive also has its own password.

Sources