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

How should I go about doing this?

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .