2017-02-12

Hide files and folders with an Encrypted disk image on Mac

1. Create an Encrypted disk image file
$ hdiutil create -size 100g -layout GPTSPUD -fs "Journaled HFS+" -volname "Secured Repository" -type SPARSEBUNDLE -encryption AES-128 EncDiskImg

Enter a new password to secure "EncryptedDisk.sparsebundle": **********
Re-enter new password: **********

created: /Users/dee/Cloud/EncDiskImg.sparsebundle
* For more options
 $ hdiutil create -help
or use Disk Utility


2. Mount
Double click the image on Finder then answer password you enter the above.
or
$ hdiutil mount EncDiskImg.sparsebundle

Enter password to access "EncDiskImg.sparsebundle": **********

/dev/disk2           GUID_partition_scheme
/dev/disk2s1        EFI
/dev/disk2s2        Apple_HFS /Volumes/Secured Repository

3. Also you can hide the file not to show on Finder. Note that the "ls" command on Terminal can list the file.
$ setfile -a V EncDiskImg.sparsebundle
* Use applescript to mount a hidden file.
do shell script "hdiutil mount /PATH/TO/EndDiskImg.sparsebundle"
It will show you a prompt to get password.

No comments:

Post a Comment