4

I would like a program that would exist on my flash drive that, when run, would

  • open an encrypted disk image with a stored password
  • then change the password to a random number
  • store it for using it the next time

Can this be done?

2
  • As this is related to your previous question, I edited out the part about what you are asking here.
    – slhck
    Jul 29, 2011 at 10:26
  • This will be fun once storing the password fails for some reason.
    – Daniel Beck
    Jul 29, 2011 at 10:45

1 Answer 1

7

If you know shell script, you can write s simple program that does that. Use hdiutil to change an encrypted disk password:

hdiutil chpass [image_name]

It will interactively ask you for your previous password and new password so you have to use some pipes or maybe expect. To generate a random number, echo $RANDOM should do. To store the passwords you can use a simple text file, if you don't mind keeping it unprotected.

2
  • It's not a tube, it's a pipe. hdiutil expects that you enter your passwords manually. If you want to automate this process you should use expect. Take a look at some Wikipedia examples: en.wikipedia.org/wiki/Expect#Examples
    – nmat
    Jul 30, 2011 at 3:27
  • Actually, there are options -oldstdinpass and -newstdinpass that allow passing in the passwords via stdin on two lines, as in (echo "oldpw"; echo "newpw") | hdiutil <img>.
    – Coroos
    Oct 19, 2016 at 7:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.