Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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

1 Answer 1

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

 
discard

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.