|
@@ -28,6 +28,25 @@ public class RandomCodeGenerator {
|
|
};
|
|
};
|
|
// C,i,j,k,M,O,P,S,U,V,W,X,Z,l
|
|
// C,i,j,k,M,O,P,S,U,V,W,X,Z,l
|
|
|
|
|
|
|
|
+ private static char[] shortLink = {
|
|
|
|
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K',
|
|
|
|
+ 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'O',
|
|
|
|
+ 'W', 'X', 'Y', 'Z',
|
|
|
|
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k',
|
|
|
|
+ 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'u', 'v', 'o',
|
|
|
|
+ 'w', 'x', 'y', 'z' ,
|
|
|
|
+ '1', '2', '3', '4', '5', '6', '7', '8', '9', '0'
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ public static String generateShortLink(int length) {
|
|
|
|
+ StringBuffer sb = new StringBuffer();
|
|
|
|
+ Random random = new Random();
|
|
|
|
+ for (int i = 0; i < shortLink.length && i < length; ++i) {
|
|
|
|
+ sb.append(shortLink[random.nextInt(shortLink.length)]);
|
|
|
|
+ }
|
|
|
|
+ return sb.toString();
|
|
|
|
+ }
|
|
|
|
+
|
|
public static String generateCode(int length) {
|
|
public static String generateCode(int length) {
|
|
StringBuffer sb = new StringBuffer();
|
|
StringBuffer sb = new StringBuffer();
|
|
Random random = new Random();
|
|
Random random = new Random();
|