Tips & Tricks: Creating a random sequence

Translation of the original in Catalan. Read it in: CatalàCastellano

Sometimes we're faced with the need to create a random sequence of characters and what we usually do is 'hammer' the keyboard. But those 'random' sequences are statistically very easily guessable and with a few thousand combinations we could discover them (thanks to the power of current processors) so well, with linux, thanks to a virtual device (very unknown to many) we can create those sequences more effectively, what better than an example to see it clearly:

dd if=/dev/random of=prova.txt bs=32 count=1

this gives us the following output:
**

1+0 records in

1+0 records out
**

and inside the file prova.txt we have a sequence of 32 characters completely random, in our case:
**

2lzªnëFÉä'«[ר,r^»N
**

do you think that's random enough???

1 comment

Comments from the old blog, as they were written. Comments are closed.

  1. —

    Per fer que la sortida xifrada surti en base64 podem usar
    aquest petit 'truquillo':



    head -c 32 /dev/random | uuencode -m - | head -2 | tail -1