in reply to Question: Generate unique/random 12-digit keys for 25,000K records, howto??
That gives something likemy $unique = time; my $key_bin = pack('N', $unique) . pack('C*', map { int(rand()*256) } 1..6); my $key_hex = unpack('H*', $key_bin);
4818e14c1662fd0dac98 \______/\__________/ | | 32-bit 48-bit unique random
You can reduce the size of the unique portion (by using substr(pack('N', $unique), 1)) and change the size of the random portion (by changing the "6") at will.
|
|---|