Re: Restrict RAND to producing 63 random bits

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



And the advantage of your approach is you can make a serialNumber longer than 8 bytes.

On 7/20/23 17:39, James wrote:
An alternative using openssl

$ printf "%016X\n" $((16#$(openssl rand -hex 8) & 0x7fffffffffffffff))
4B0193AE43934F09

To get the leading zeros so it will generate an 8-byte serial number, I added:

printf "%016X\n" $(shuf -rn 1 -i 1-9223372036854775807 --random-source=/dev/urandom)

an example output is:

0E12E1A664C30AE1

I had to run it a couple dozen times before it generated a small enough value to need to pad it.



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux