Java Utililty Methods ID Value Create

List of utility methods to do ID Value Create

Description

The list of methods to do ID Value Create are organized into topic(s).

Method

StringcreateID()
Generates a unique Id for Authentication Requests
byte[] bytes = new byte[20]; 
new Random().nextBytes(bytes);
char[] charMapping = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p' };
char[] chars = new char[40];
for (int i = 0; i < bytes.length; i++) {
    int left = (bytes[i] >> 4) & 0x0f;
    int right = bytes[i] & 0x0f;
    chars[i * 2] = charMapping[left];
...
StringcreateID()
Create a randomly generated string conforming to the xsd:ID datatype.
byte[] bytes = new byte[20]; 
random.nextBytes(bytes);
char[] chars = new char[40];
for (int i = 0; i < bytes.length; i++) {
    int left = (bytes[i] >> 4) & 0x0f;
    int right = bytes[i] & 0x0f;
    chars[i * 2] = charMapping[left];
    chars[i * 2 + 1] = charMapping[right];
...
StringgenerateId()
generate Id
long seed1 = System.currentTimeMillis();
while (seed1 == seed)
    seed1 = System.currentTimeMillis(); 
seed = seed1;
Random r = new Random(seed);
return Integer.toString(r.nextInt(), 16) + "-" + Integer.toString(r.nextInt(65535), 16) + "-"
        + Integer.toString(r.nextInt(65535), 16) + "-" + Integer.toString(r.nextInt(65535), 16);
intgenerateId()
Generates a random, valid id to use when fetching a fact.
Random rand = new Random();
int id = rand.nextInt(989) + 1;
while (id > 497 && id < 651) {
    id = rand.nextInt(989) + 1;
return id;
StringgenerateId()
generate Id
int id = 1000000 + rng.nextInt(8999999);
String sid = String.valueOf(id);
return ("id" + sid);
byte[]generateId()
generate Id
byte[] id = new byte[RANDOM_ID_LENGTH];
new Random().nextBytes(id);
return id;
StringgenerateID(final String message)
Generates a sensor id from description and current time as long.
final long autoGeneratredID = new DateTime().getMillis();
final String concate = message + Long.toString(autoGeneratredID);
return bytesToHex(messageDigest.digest(concate.getBytes()));
intgenerateID(int seed)
generate ID
Random rand = new Random(seed);
int id = rand.nextInt();
if (id > 0) {
    id = -id;
return id;
StringgenerateID(String origin)
generate ID
java.security.MessageDigest md;
String pwd = null;
try {
    md = MessageDigest.getInstance("MD5");
    byte[] b = origin.getBytes("UTF-8");
    byte[] hash = md.digest(b);
    String str = byteArrayToHexString(hash);
    return str;
...
StringgenerateId(String salt)
generate Id
return generateId(salt, "MD5");