Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

Cross-platform file encryption with TrueCrypt (See related posts)

# first download & install the free, open-source TrueCrypt program from http://www.truecrypt.org/downloads.php

ls -ld /Applications/TrueCrypt.app
ls -l /Applications/TrueCrypt.app/Contents/MacOS/TrueCrypt

open -a TrueCrypt

1. click "Create Volume"
2. TrueCrypt Volume Creation Wizard: select "Create a file container"
3. click Next
4. Volume Type: select "Standard TrueCrypt volume"
5. click Next
6. Volume Location: click "Select File ..."
7. navigate to ~/Desktop with the file browser, then click "New Folder"
8. enter "Name of new folder": TrueCrypt, then click Create
9. enter in "Save As": MyTrueCrypt, then click Save
10. Volume Location: the "Select File ..." field should contain /PATH/TO/Desktop/TrueCrypt/MyTrueCrypt
11. click Next
12. Encryption Options:
    Encryption Algorithm: AES
    Hash Algorithm: RIPEMD-160
13. click Next
14. Volume Size: 3 MB
15. click Next
16. Volume Password: *********************  (more than 20 characters recommended)
17. click Next
18. Format Options: Filesystem Options: Filesystem type: select FAT
19. click Next
20. Volume Format: Move your mouse as randomly as possible within this window
21. click Format
22. "The TrueCrypt volume has been successfully created."
23. click OK
24. Volume Created
25. click Exit
26. click Close (to quit TrueCrypt)

open -a TrueCrypt

1. click "Select File ..."
2. navigate with the file browser to /PATH/TO/Desktop/TrueCrypt/MyTrueCrypt
3. click Open
4. click Mount and enter your password: *********************
5. double-click: Slot 1 : Volume: /PATH/TO/Desktop/TrueCrypt/MyTrueCrypt  Size: ...

touch '/Volumes/NO NAME/file.txt'    # or copy a text file to '/Volumes/NO NAME'
echo 'This is a test!' >> "$_"
cat '/Volumes/NO NAME/file.txt'
ls -l "$_"
# hdiutil unmount '/Volumes/NO NAME'

6. click Dismount
7. click Close


# References:
# Beginner's Tutorial, http://www.truecrypt.org/docs/?s=tutorial
# http://www.truecrypt.org/faq.php
# http://blogs.oreilly.com/digitalmedia/2008/03/truecrypt-51-open-source-file.html
# http://www.askstudent.com/security/a-step-by-step-guide-on-encrypting-files-using-truecrypt/
# http://techvj.blogspot.com/2007/03/secure-email-attachments-with-truecrypt.html


#------------------------------------------------


# download & install OSXCrypt, http://www.osxcrypt.org
man ocutil
ocutil
ocutil create -help

kextstat | grep OSXCrypt
ioreg -lw 0 | grep -i osxcrypt


# Example Usage

# Create a 200M volume, FAT formatted, using Seprent-Twofish-AES
ocutil create -verbose -fat -algorithm Serpent-Twofish-AES -size 200M MyCryptedVolume.img

# The same, but using also keyfiles
ocutil create -verbose -fat -keyfiles MyKeyFile1,MyKeyFile2,MyKeyFile3 -algorithm Serpent-Twofish-AES -size 200M MyCryptedVolume.img

# The same, but only using the keyfiles
ocutil create -verbose -fat -nopass -keyfiles MyKeyFile1,MyKeyFile2,MyKeyFile3 -algorithm Serpent-Twofish-AES -size 200M MyCryptedVolume.img

# Create an hidden volume of 100M, FAT formatted, using Serpent-AES, in a previously created volume
ocutil create -verbose -hidden -fat -algorithm Serpent-AES -size 100M MyCryptedVolume.img

# If the outer volume requires keyfiles you'll have something like ...
ocutil create -verbose -hidden -fat -algorithm Serpent-AES -keyfiles MyKeyFile1,MyKeyFile2,MyKeyFile3 -size 100M MyCryptedVolume.img

# If you want to add keyfiles to the hidden volumes to an outer volume with keyfiles, your command will be something like ...
ocutil create -verbose -hidden -fat -algorithm Serpent-AES -keyfiles MyKeyFile1,MyKeyFile2,MyKeyFile3 -size 100M -hidden_keyfiles MyHiddenKeyFile MyCryptedVolume.img

# The same as before but only with keyfiles for the hidden volume
ocutil create -verbose -hidden -fat -algorithm Serpent-AES -keyfiles MyKeyFile1,MyKeyFile2,MyKeyFile3 -size 100M -hidden_nopass -hidden_keyfiles MyHiddenKeyFile MyCryptedVolume.img

# Attaching a volume
ocutil attach -verbose MyCryptedVolume.img

# If the volume requires keyfiles
ocutil attach -verbose -keyfiles MyKeyFile1,MyKeyFile2,MyKeyFile3 MyCryptedVolume.img

# The same as before but only with keyfiles
ocutil attach -verbose -nopass -keyfiles MyKeyFile1,MyKeyFile2,MyKeyFile3 MyCryptedVolume.img

# Attaching an hidden volume
ocutil attach -hidden -verbose MyCryptedVolume.img

# Attaching a volume protecting its hidden volume
ocutil attach -protect_hidden -verbose MyCryptedVolume.img

# Detaching a volume
ocutil detach -verbose MyCryptedVolume.img
#ocutil detach -verbose device-name

# Generating one or more keyfiles
ocutil genkey -verbose output1.key [output2.key ...]

You need to create an account or log in to post comments to this site.