What's the simplest way to password protect a text file?
Solution 1:
You can put the file into an encrypted disk image.
- Open "/Applications/Utilities/Disk Utility"
- File > New > New Blank Image...
-
In the new image dialog make sure to choose:
- Encryption = 128 or 256-bit AES
- Image Format = read/write disk image
Because you chose encryption, you will be prompted to set a password for the disk image
You now have a password-protected disk image that you can save any kind of file in.
Solution 2:
Assuming you're the file's owner, a built-in and system-wide way to do this would be to adjust the file's permissions so that only a specific user or users (I'm assuming you want to lock the file so only you can view/edit it) can read or write to the file.
As Mark pointed out in the comments, however, this only protects you if:
- No other user has admin rights to the machine, and
- No one gains access to the machine while you're logged in
Making Coconut Man's solution by far a better one. I'll leave this answer here as an alternative that may be helpful in similar situations.
Solution 3:
You can print->save as PDF->password protect the PDF. It's not as transparent as having the .txt in a DMG
, but it's easy enough to copy/paste the contents when it's time to edit.
Another container version akin to a DMG
is OpenPGP
. The suite for OS X is pretty nice, and it adds encrypt/decrypt to the services menu. It's very easy to right click your text file, choose 'Encrypt File' enter a password, verify, done.
Don't forget Keychain Access
as well. It has the ability to create Secure Notes
, which are password protected by the keychain they are stored in.