Here you can find the source of randomHexNumber(final int length)
public static final String randomHexNumber(final int length)
//package com.java2s; /*/*from w w w .j a va 2 s .c o m*/ * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ import java.util.*; public class Main { /** * Pseudo-random number generator object for use with randomString(). The * Random class is not considered to be cryptographically secure, so only * use these random Strings for low to medium security applications. */ private static Random randGen = new Random(); private static char[] hexNumbers = "0123456789abcdef".toCharArray(); public static final String randomHexNumber(final int length) { char[] randBuffer = new char[length]; for (int i = 0; i < randBuffer.length; i++) { randBuffer[i] = hexNumbers[randGen.nextInt(15)]; } return (new String(randBuffer)); } }