-
Notifications
You must be signed in to change notification settings - Fork 0
/
password.java
41 lines (40 loc) · 1.22 KB
/
password.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import java.util.Scanner;
import java.lang.Math;
import java.util.Random;
import java.util.Collections;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
public class A{
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
String p="",d="";
int v=0;
int num1=1000;
int num2=1;
int j=(int)(Math.random()*(num1-num2-8)-num2);
int b= (int)(Math.random()*(num1-num2-8)-num2);
v=b;
String s="qwertyuioplkjgfdsazxcvbnmQWERTYUIOPLKJHGFDSAZXCVBNM";
int len=s.length();
Random r=new Random();
char c = s.charAt(r.nextInt(len));
d=c+"";
String k="/.,~!@#$%^&:?><";
int l=k.length();
char u=k.charAt(r.nextInt(l));
p=u+"";
String m=p+d+v;
List<Character> chars = new ArrayList<Character>();
for(char c1 : m.toCharArray()){
chars.add(c1);
}
Collections.shuffle(chars);
StringBuilder sb = new StringBuilder();
for(char c1 : chars){
sb.append(c1);
}
String shuffledString = sb.toString();
System.out.println(shuffledString+j);
}
}