using
System;
using
System.Collections.Generic;
class
GFG {
static
string
add_more_char(
string
str,
int
need)
{
int
pos = 0;
Random randm =
new
Random();
string
low_case =
"abcdefghijklmnopqrstuvwxyz"
;
for
(
int
i = 0; i < need; i++) {
pos = randm.Next(1,1000) % str.Length;
str = str.Insert(pos,low_case[randm.Next(1000)
% 26].ToString());
}
return
str;
}
static
string
suggester(
int
l,
int
u,
int
d,
int
s,
string
str)
{
Random randm =
new
Random();
string
num =
"0123456789"
;
string
low_case =
"abcdefghijklmnopqrstuvwxyz"
;
string
up_case =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
;
string
spl_char =
"@#$_()!"
;
int
pos = 0;
if
(l == 0) {
pos = randm.Next(1,1000) % str.Length;
str = str.Insert(pos,low_case[randm.Next(1,
1000) % 26].ToString());
}
if
(u == 0) {
pos = randm.Next(1,1000) % str.Length;
str = str.Insert(pos,up_case[randm.Next(
1,1000) % 26].ToString());
}
if
(d == 0) {
pos = randm.Next(1,1000) % str.Length;
str = str.Insert(pos,num[randm.Next(1,1000)
% 10].ToString());
}
if
(s == 0) {
pos = randm.Next(1,1000) % str.Length;
str = str.Insert(pos,spl_char[randm.Next(
1,1000) % 7].ToString());
}
return
str;
}
static
void
generate_password(
int
n,
string
p)
{
int
l = 0, u = 0, d = 0, s = 0, need = 0;
string
suggest;
for
(
int
i = 0; i < n; i++) {
if
(p[i] >= 97 && p[i] <= 122)
l = 1;
else
if
(p[i] >= 65 && p[i] <= 90)
u = 1;
else
if
(p[i] >= 48 && p[i] <= 57)
d = 1;
else
s = 1;
}
if
((l + u + d + s) == 4) {
Console.WriteLine(
"Your Password is Strong\n"
);
return
;
}
else
Console.WriteLine(
"Suggested password\n "
);
for
(
int
i = 0; i < 10; i++) {
suggest = suggester(l, u, d, s, p);
need = 8 - suggest.Length;
if
(need > 0)
suggest = add_more_char(suggest, need);
Console.WriteLine(suggest +
"\n"
);;
}
}
public
static
void
Main()
{
string
input_string =
"geek@2018"
;
generate_password(input_string.Length, input_string);
}
}