In the process of playing with backing up to disc images I wanted to play around how to automate the password entry. I may get into why in a future post. Whatever you do, do not use a plain dictionary word to secure your images. Here is why. I based it on the scripts I found at: http://ask.metafilter.com/47171/How-to-crack-a-disk-image
Modified and tested. Worked like a champ when I added my chosen password to a dictionary text file of words. In the below example I used a path to where I have a large collection of dictionary files used for password cracking in forensics etc. This is not the fastest thing in the world but it works if the chosen password shows up in the word lists you throw at the image.
for word in $(cat /Volumes/ExternalDrive/Dictionaries/test.txt | grep -v “#”)
echo -n $word | hdiutil attach /Volumes/iPod/Backup/Backup.sparseimage -stdinpass
if [[ $? = 0 ]]
echo “Password found!”
echo “password not found :(”