Exemplo n.º 1
1
 private static String generateToken() {
   final StringBuilder builder = new StringBuilder(260);
   while (builder.length() < 256) {
     builder.append(Long.toHexString(TOKEN_GENERATOR.nextLong()));
   }
   return builder.substring(0, 256);
 }
Exemplo n.º 2
0
 public static String generatePassword() {
   String charset = "0123456789abcdefghijklmnopqrstuvwxyz";
   Random rand = new Random(System.currentTimeMillis());
   StringBuilder sb = new StringBuilder();
   for (int i = 0; i < charset.length(); i++) {
     int pos = rand.nextInt(charset.length());
     sb.append(charset.charAt(pos));
   }
   return sb.toString();
 }