Created by [CecilWesterhof].
'''Getting Random Bytes on a *NIX System'''
There are several reasons you want to get a set of random bytes. I wrote a version for *NIX systems:
======
proc getRandomBytesNix {count {secure False}} { if ${secure} {
set randFile /dev/random
} else {
set randFile /dev/urandom
} set randDev [open ${randFile} rb]
set random [read ${randDev} ${count}]
close ${randDev}
return ${random}
}
======
In almost all cases you do not need /dev/random, so normally you would call it like:
======
set random [getRandomBytesNix 16]
======
----
As always: comments, tips and questions are appreciated.
<<categories>>Linux | Utilities