Question

In: Computer Science

Write a script in C that will do the following : 1. Create the directory ZHW3....

Write a script in C that will do the following :

1. Create the directory ZHW3.

2. Verify that the directory is created by display all information related to the directory and not just the name of the directory.

3. Assume that the input from the command is used to validate password strength. Here are a few assumptions for the password string.

• Length – minimum of 8 characters.

• Contain alphabets , numbers , and @ # $ % & * symbols.

• Include both the small and capital case letters.

If the password doesn’t comply with any of the above conditions, then the script should report it as a <Weak Password>. Otherwise, the script should report it as a <Strong Password>.

The script must save the strong password it in a password file ( password.txt ) in ZHW3 Directory. If the file does not exist , create the file.

Repeat until N or n is entered.

If you enter Y|y, then new password is entered from the keyboard

Solutions

Expert Solution

// C++ code to validate a password  
#include<bits/stdc++.h> 

using namespace std; 

  
// A utility function to check  
// whether a password is valid or not  
char* dirname = "ZHW3";

bool isValid(string password)  
{  

  

    // For checking if password length  

    // is between 8 and 15  

    if (!((password.length() >= 8) &&  

          (password.length() <= 15))) 

        return false;  

  

    // To check space  

    if (password.find(" ") != 

        std::string::npos) 

        return false;  

  

    if (true) 

    {  

        int count = 0;  

  

        // Check digits from 0 to 9  

        for(int i = 0; i <= 9; i++) 

        {  

              

            // To convert int to string  

            string str1 = to_string(i);  

  

            if (password.find(str1) !=  

                std::string::npos)  

                count = 1;  

        }  

        if (count == 0)  

            return false;  

    }  

  

    // For special characters  

    if (!((password.find("@") != std::string::npos) || 

          (password.find("#") != std::string::npos) || 

          (password.find("!") != std::string::npos) || 

          (password.find("~") != std::string::npos) || 

          (password.find("$") != std::string::npos) || 

          (password.find("%") != std::string::npos) || 

          (password.find("^") != std::string::npos) || 

          (password.find("&") != std::string::npos) || 

          (password.find("*") != std::string::npos) || 

          (password.find("(") != std::string::npos) || 

          (password.find(")") != std::string::npos) || 

          (password.find("-") != std::string::npos) || 

            (password.find("+") != std::string::npos) || 

          (password.find("/") != std::string::npos) || 

          (password.find(":") != std::string::npos) || 

          (password.find(".") != std::string::npos) || 

          (password.find(",") != std::string::npos) || 

          (password.find("<") != std::string::npos) || 

          (password.find(">") != std::string::npos) || 

          (password.find("?") != std::string::npos) || 

          (password.find("|") != std::string::npos))) 

        return false; 

      

    if (true) 

    {  

        int count = 0;  

  

        // Checking capital letters  

        for(int i = 65; i <= 90; i++)  

        {  

              

            // Type casting  

            char c = (char)i; 

            string str1(1, c); 

              

            if (password.find(str1) != 

                std::string::npos)  

                count = 1;  

        }  

        if (count == 0)  

            return false;  

    }  

  

    if (true) 

    {  

        int count = 0;  

  

        // Checking small letters  

        for(int i = 90; i <= 122; i++) 

        {  

              

            // Type casting  

            char c = (char)i;  

            string str1(1, c);  

  

            if (password.find(str1) !=  

                std::string::npos) 

                count = 1; 

        }  

        if (count == 0)  

            return false; 

    }  

  

    // If all conditions fails  

    return true;  
}  

  
// Driver code  

int main()  
{  

    string password1 = "ZHW3";  

      

    if (isValid(password1))  

        cout << "Valid Password" << endl;  

    else

        cout << "Invalid Password" << endl; 

  

    string password2 = "$ZHW3" ; 

      

    if (isValid(password2))  

        cout << "Valid Password" << endl;  

    else

        cout << "Invalid Password" << endl; 
}

Related Solutions

UNIX/LINUX SCRIPT: Create a named directory and verify that the directory is there by listing all...
UNIX/LINUX SCRIPT: Create a named directory and verify that the directory is there by listing all its contents. Write a shell script to validate password strength. Here are a few assumptions for the password string.   Length – a minimum of 8 characters. • Contain alphabets , numbers , and @ # $ % & * symbols. • Include both the small and capital case letters. give a prompt of Y or N to try another password and displays an error...
Write a bash script to find all the files ending with .c recursively for every directory...
Write a bash script to find all the files ending with .c recursively for every directory in your current working directory, then copy each one to a folder called programs, need handle duplicates by appending the number to the end of the file (ex main.c main-1.c ) compile them and generate a report report should look like: main.c compiles prog2.c failed main-2.c compiles etc.
Write a script that prompts the user for a pathname of a file or directory and...
Write a script that prompts the user for a pathname of a file or directory and then responds with a description of the item as a file along with what the user's permissions are with respect to it (read, write, execute).
Write a program in c++ that maintains a telephone directory. The Telephone directory keeps records of...
Write a program in c++ that maintains a telephone directory. The Telephone directory keeps records of people’s names and the corresponding phone numbers. The program should read a transaction file and report the result into an output file. The transaction file can include commands such as “Add”, “Delete”, “Display”, and “Update”, and “Search”. Each command is written in one line with a few other information. The “Display” Command should simply display everyone in the directory on the screen The “Add”...
Write a bash script file that tests each file entry in the current directory. It should...
Write a bash script file that tests each file entry in the current directory. It should determine if it is a file or directory. If it is a file, it will determine if it is readable or not. If it is readable, it will display only the first 4 lines to the terminal in sorted order (just sort the first 4 lines). If it is a directory, it should display the contents of that directory (the files and subdirectories). NOTE:...
Using PowerShell ISE or VSCode, create a PowerShell script that will do the following: Create functions...
Using PowerShell ISE or VSCode, create a PowerShell script that will do the following: Create functions to get the following information Local username Local machine name Time zone Current Date Output the data that was collected to the screen Upload the script. Paste a screenshot of the results here
Task: 2.1 : Shell Scripting Task1 :Traditional hello world script Open terminal create Lab01 directory and...
Task: 2.1 : Shell Scripting Task1 :Traditional hello world script Open terminal create Lab01 directory and use cd command to move into the directory Open a new file script hello.sh using vi editor # vi hello.sh Type the following lines #!/bin/bash           echo Hello World     Save the file and return back to terminal How to Runhello.sh Adding Execute Permission Checking current permission        # ls -la hello.sh Adding Execute permission # chmod u+x hello.sh   Check whether execute permission is added # ls...
Write C++ program to do the following: 1. Create integer array size of 10 2. Ask...
Write C++ program to do the following: 1. Create integer array size of 10 2. Ask user input the values of the array's element using for loop 3. pass the array to void function. in void function do the following: a. Find the maximum of the array. b. Compute the element average c. Find out how many numbers are above the average d. Find out and print how many numbers are below the average e. find out how many numbers...
Write a program in c++ to do the following: 2. Create an array to hold up...
Write a program in c++ to do the following: 2. Create an array to hold up to 20 integers. 3. Create a data file or download attached text file (twenty_numbers.txt) that contains UP TO 20 integers. 4. Request the input and output file names from the user. Open the files being sure to check the file state. 5. Request from the user HOW MANY numbers to read from the data file, up to twenty. Request the number until the user...
Using PowerShell ISE or VSCode, create a PowerShell script that will do the following: You are...
Using PowerShell ISE or VSCode, create a PowerShell script that will do the following: You are going to create an HTML web page report from a standard processed report. You will use the text file “STUDENTS.TXT” located on Canvas. The script must meet the following requirements: The output file should be named ITS3410-{your name}.htm Every line of data that has a student number (9999-9999) must be included in the report All data must be trimmed No leading white space No...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT