Java Password Generate generatePassword()

Here you can find the source of generatePassword()

Description

generate Password

License

Apache License

Declaration

public static String generatePassword() 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Random;

public class Main {

    public static String generatePassword() {
        int[] array = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
        Random rand = new Random();
        for (int i = 10; i > 1; i--) {
            int index = rand.nextInt(i);
            int tmp = array[index];
            array[index] = array[i - 1];
            array[i - 1] = tmp;// w  w w . j a v a2 s. c  om
        }
        int result = 0;
        for (int i = 0; i < 6; i++)
            result = result * 10 + array[i];
        return String.valueOf(result);
    }
}

Related

  1. generatePassword()
  2. generatePassword()
  3. generatePassword()
  4. generatePassword()
  5. generatePassword()
  6. generatePassword(int lenght)
  7. generatePassword(int length)
  8. generatePassword(int length)