Searching...
Sunday, June 1, 2014

Auto Generate Password In Java /servlet /Struts2

June 01, 2014
                               Auto Generate Password In Java /servlet /Struts2
package java9r.blogspot.com;
public class AutoInc {
      /** Minimum length for a decent password */
      public static final int MIN_LENGTH = 70;

      /** The random number generator. */
      protected static java.util.Random r = new java.util.Random();
      protected static char[] goodChar = { 'a', 'b', 'c', 'd', 'e', 'f', 'g',
          'h', 'j', 'k', 'm', 'n', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
          'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K',
          'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
          '2', '3', '4', '5', '6', '7', '8', '9', }; 
      /* Generate a Password object with a random password. */
      public static String getNext() {
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < MIN_LENGTH; i++) {
          sb.append(goodChar[r.nextInt(goodChar.length)]);
        }
        return sb.toString();
      }

      public static void main(String[] argv) {
        for (int i = 0; i < 1; i++) {
          System.out.println(AutoInc.getNext());
        }
      }
    }

4 comments:

ads2