Here you can find the source of randomHex(int length)
public static String randomHex(int length)
//package com.java2s; /*/*from w w w .j av a 2 s .c o m*/ * Copyright (C) 2010 - 2012 Jenia Software. * * This file is part of Sinekarta * * Sinekarta is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Sinekarta is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * */ public class Main { public static String randomHex(int length) { StringBuilder buf = new StringBuilder(); for (int i = 0; i < length; i++) { buf.append(Long.toHexString((long) (Math.random() * 16))); } return buf.toString(); } }