Skip to content

Commit b60f850

Browse files
authored
time's coming when I'll no more speak2u in figures
I have spoken these things to you in figures of speech. But the time is coming when I will no more speak to you in figures of speech, but will tell you plainly about the Father. (John 16:25)
1 parent db0a8bc commit b60f850

1 file changed

Lines changed: 86 additions & 0 deletions

File tree

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
2+
//I have spoken these things to you in figures of speech. But the time is coming when
3+
//I will no more speak to you in figures of speech, but will tell you plainly about the Father. (John 16:25)
4+
5+
package com.javarush.task.task32.task3204;
6+
7+
import java.io.ByteArrayOutputStream;
8+
9+
/*
10+
Генератор паролей
11+
*/
12+
public class Solution {
13+
public static void main(String[] args) {
14+
ByteArrayOutputStream password = getPassword();
15+
System.out.println(password.toString());
16+
}
17+
18+
public static ByteArrayOutputStream getPassword() {
19+
ByteArrayOutputStream output = new ByteArrayOutputStream();
20+
21+
String letters = "abcdefghijklmnopqrstuvwxyz";
22+
String digits = "1234567890";
23+
StringBuffer pwd = new StringBuffer();
24+
25+
for (int i=0; i<4; i++) {
26+
pwd.append(letters.charAt((int)(Math.random()*26)));
27+
}
28+
for (int i=0; i<2; i++) {
29+
pwd.append(digits.charAt((int)(Math.random()*10)));
30+
}
31+
for (int i=0; i<2; i++) {
32+
pwd.append(letters.toUpperCase().charAt((int)(Math.random()*26)));
33+
}
34+
35+
try {
36+
output.write(pwd.toString().getBytes());
37+
} catch (Exception e)
38+
{
39+
40+
}
41+
42+
return output;
43+
}
44+
}
45+
46+
/*
47+
Генератор паролей
48+
49+
Реализуй логику метода getPassword, который должен возвращать ByteArrayOutputStream, в котором будут байты пароля.
50+
51+
Требования к паролю:
52+
53+
1) 8 символов.
54+
55+
2) только цифры и латинские буквы разного регистра.
56+
57+
3) обязательно должны присутствовать цифры, и буквы разного регистра.
58+
59+
Все сгенерированные пароли должны быть уникальные.
60+
61+
62+
63+
Пример правильного пароля:
64+
65+
wMh7smNu
66+
67+
68+
69+
70+
71+
Требования:
72+
73+
1. Класс Solution должен содержать метод getPassword(), который возвращает ByteArrayOutputStream со сгенерированным паролем.
74+
75+
2. Длина пароля должна составлять 8 символов.
76+
77+
3. Пароль должен содержать хотя бы одну цифру.
78+
79+
4. Пароль должен содержать хотя бы одну латинскую букву нижнего регистра.
80+
81+
5. Пароль должен содержать хотя бы одну латинскую букву верхнего регистра.
82+
83+
6. Пароль не должен содержать других символов, кроме цифр и латинских букв разного регистра.
84+
85+
7. Сгенерированные пароли должны быть уникальными.
86+
*/

0 commit comments

Comments
 (0)