/**
* Copyright (c) 2005-2012 springside.org.cn
*
* Licensed under the Apache License, Version 2.0 (the "License");
*/
Package com.minxinloan.common.utils;
Import Java.security.SecureRandom;
Import Java.util.UUID;
/**
* Encapsulates various tool classes that generate a unique ID algorithm.
* @author Calvin
* @version 2013-01-15
*/
public class Identities {
private static SecureRandom random = new SecureRandom ();
/**
* Encapsulates the UUID that comes with the JDK, generated by random numbers, and split in the middle.
*/
public static String uuid () {
Return Uuid.randomuuid (). toString ();
}
/**
* Encapsulates the JDK's own uuid, generated by random numbers, middle none-split.
*/
public static String Uuid2 () {
Return Uuid.randomuuid (). toString (). ReplaceAll ("-", "" ");
}
/**
* Use SecureRandom to randomly generate long.
*/
public static long Randomlong () {
Return Math.Abs (Random.nextlong ());
}
/**
* SecureRandom randomly generated bytes based on Base62 encoding.
*/
public static String randomBase62 (int length) {
byte[] randombytes = new Byte[length];
Random.nextbytes (randombytes);
Return encodes.encodebase62 (randombytes);
}
}
Encapsulates various tool classes that generate a unique ID algorithm