Esempio n. 1
0
 // Generates new password by build each part and storing it in arrayList
 public static String generateNewPassword(boolean l, boolean u, boolean n, boolean s, int len) {
   ArrayList<Integer> cs = new ArrayList<Integer>();
   if (l) {
     for (int i = 0; i < 26; i++) {
       cs.add(97 + i);
     }
   }
   if (u) {
     for (int i = 0; i < 26; i++) {
       cs.add(65 + i);
     }
   }
   if (n) {
     for (int i = 0; i < 10; i++) {
       cs.add(48 + i);
     }
   }
   if (s) {
     for (int i = 0; i < 10; i++) {
       cs.add(33 + i);
     }
     for (int i = 0; i < 7; i++) {
       cs.add(58 + i);
     }
     for (int i = 0; i < 6; i++) {
       cs.add(91 + i);
     }
     for (int i = 0; i < 4; i++) {
       cs.add(123 + i);
     }
   }
   StringBuilder sb = new StringBuilder();
   for (int i = 0; i < len; i++) {
     sb.append(Character.toChars(cs.get((int) (Math.random() * cs.size()))));
   }
   return sb.toString();
 }
 /**
  * Appends the encoded Unicode code point. The code point is converted to a {@code char[]} as
  * defined by {@link Character#toChars(int)}.
  *
  * @param codePoint the Unicode code point to encode and append.
  * @return this builder.
  * @see Character#toChars(int)
  */
 public StringBuilder appendCodePoint(int codePoint) {
   append0(Character.toChars(codePoint));
   return this;
 }