Hi all,
I need to generate 12 digit Hex numbers in KSH on Solaris
Thanks
Hi all,
I need to generate 12 digit Hex numbers in KSH on Solaris
Thanks
Start with this Python program, hex12.py
.
hex12.py
#!/usr/bin/env python
import random
import hashlib
h= hashlib.sha1(str(random.random())).hexdigest()
print h[:12]
In your shell you can now use hex.py
to create 12 hex digits on standard out.
Try this one:
DIGITS=`head -c 6 /dev/urandom | od -x | head -n 1 | sed -e 's/^0* //' -e 's/ //g'
#!/bin/ksh
set -A hex 0 1 2 3 4 5 6 7 8 9 A B C D E F
for i in {1..12}
do
printf ${hex[$((RANDOM%16))]}
done