import java.security.SecureRandom;
public class RandomHexGenerator {
public static void main(String[] args) {
String hexstr = generateHex(8);
System.out.println("Random hexadecimal: " + hexstr);
}
public static String generateHex(int length) {
SecureRandom random = new SecureRandom();
StringBuilder hexstring = new StringBuilder();
for (int i = 0; i < length; i++) {
int rndvalue = random.nextInt(16);
hexstring.append(Integer.toHexString(rndvalue));
}
return hexstring.toString();
}
}
/*
run:
Random hexadecimal: f23dcd9e
*/