$ hdiutil create -size 100g -layout GPTSPUD -fs "Journaled HFS+" -volname "Secured Repository" -type SPARSEBUNDLE -encryption AES-128 EncDiskImg* For more options
Enter a new password to secure "EncryptedDisk.sparsebundle": **********
Re-enter new password: **********
created: /Users/dee/Cloud/EncDiskImg.sparsebundle
$ hdiutil create -helpor 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.