Write a program that can allow users to choose passwords of exactly length Len f
ID: 3700207 • Letter: W
Question
Write a program that can allow users to choose passwords of exactly length Len from 20 unique characters and users have to change passwords for every six months. The program should find out the length of the password. (Ay programing language is acceptable)
This is the description:
Imagine that you are a system administrator developing a password-based authentication system that can allow users to choose passwords of exactly length len from 20 unique characters. Suppose there is an attacker who wants to guess the password of a
user by launching a brute-force attack using a machine that can verify 1000 possible guesses per second. As a system administrator, you want to make sure that an attacker cannot successfully guess a password for a period of 6 months (assuming that users change passwords for every six months). Based on the above input values, please write a program to find out the length of the password (i.e., the value of len) in order to achieve your goal?
Explanation / Answer
#include <bits/stdc++.h>
using namespace std;
void printStrong(string& input)
{
int z = input.length();
bool hasLower = false, hasUpper = false; // checking lower alphabet in string
bool hasDigit = false, specialChar = false;
string normalValue = "abcdefghijklmnopqrstuvwxyzA1234567890!@#$%^&*";
for (int x = 0; x<z; x++){
if (islower(input[x]))
hasLower = true;
if (isupper(input[x]))
hasUpper = true;
if(isdigit(input[x]))
hasDigit = true;
size_t special = input.find_first_not_of(normalValue);
if(special != string:: npos)
specialChar = true;
}
cout<< "Strength of password:-"; // Strength of password
if (hasLower && hasUpper && hasDigit && specialChar && (z>=8))
cout<< "Strong" << endl;
else if ((hasLower || hasUpper) && specialChar && (z>=6))
cout<<"Moderate" <<endl;
else
cout<<"weak" << endl;
}
int main()
{
string input = "ManIsMan!@1714";
printStrong(input);
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.