Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to generate several cryptographically random numbers in OSX and save it to a text file.

How should I go about doing this?

share|improve this question

The /dev/random file on OS X is fairly good since it uses the Yarrow algorithm which many consider to be fairly secure in generating random numbers.

You can use dd to pull a character at a time off the stream and as long as you use caution in converting it into a number range you care to see in your text file, this is a fairly painless way to get some decent randomness.

dd if=/dev/random bs=1 count=1 2>/dev/null >> /path/to/your/file
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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