You were never here, you didn't see anything..

Generate HEX Keys


It was asked recently how to generate a random HEX key for something like WEP. A bash one liner can do this for you using the following:

string=0123456789ABCDEF && for i in $(seq 1 32); do pos=$(($RANDOM%15)) && key=${key}${string:$pos:1}; done && echo $key

If you run this on the command line and want to do things again make sure you unset the $key or it will include the previous $key in your new key.

unset key

To get the size you need divide the bits by 8 and change the number 32 as needed. So for a 128 bit key you divide 128 by 8 or:

echo 128/8 | bc

Some base numbers are:

64 bit  = 8
104 bit = 13
128 bit = 16
256 bit = 32

Have any Question or Comment?

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This blog is kept spam free by WP-SpamFree.

Most who fail…

Most who fail have yet to really try!