In this assignment you will write the code for two functions
Solution
//Feb_3_encryptPwd.h
#include<string.h>
#include<stdio.h>
 #include<ctype.h>
 #include<stdlib.h>
 #include<string>
 const int MIN_RANGE = 33;
 const int MAX_RANGE = 122;
 //function declaration of isValidPassword and encrypt functions
 bool isValidPassword(char *s, char spec[], int size);
 char *encrypt(char *s, int key);
 bool isspecial(char c, char spec[], int size);
-------------------------------------------------------------------------------------------------
//Feb_3_encryptPwd.cpp
#include\"Feb_3_encryptPwd.h\"
//function definition of isValidPassword and encrypt functions
 bool isValidPassword(char *s,char spec[],int size)
 {
    int i, CapitalCnt = 0, LowerCnt = 0, DigitCnt = 0, SplCnt = 0, otherCnt =0;
   if (strlen(s) < 8)
    {
        //printf(\"Password must be 8 characters\ \");
        return false;
    }
    if (strlen(s) > 10)
    {
        //printf(\"Password must be 10 characters at most\ \");
        return false;
    }
   
    for (i = 0; i < strlen(s); i++)
    {
        if (!isupper(s[i]) && !islower(s[i]) && !isdigit(s[i]) && !isspecial(s[i], spec, size))
            otherCnt++;
        if (isupper(s[i]))
            CapitalCnt++;
        if (islower(s[i]))
            LowerCnt++;
        if (isdigit(s[i]))
            DigitCnt++;
        //if (s[i] == \'#\' || s[i] == \'$\' || s[i] == \'%\' || s[i] == \'&\' || s[i] == \'!\' || s[i] == \'?\' || s[i] == \'@\')
        if ( isspecial(s[i],spec,size))
            SplCnt ++;
       
    }
    if (CapitalCnt < 1)
    {
        //printf(\"Password should contain atlease one capital character\ \");
        return false;
    }
    if (LowerCnt < 1)
    {
        //printf(\"Password should contain atlease one lower character\ \");
        return false;
    }
    if (DigitCnt < 1)
    {
        //printf(\"Password should contain atlease one digit character\ \");
        return false;
    }
    if (SplCnt < 1)
    {
        //printf(\"Password should contain atlease one special character\ \");
        return false;
    }
    if (otherCnt >0)
    {
        //printf(\"Password contains character which is not letter , digit or special character\ \");
        return false;
    }
return true;
}
 char *encrypt(char *s, int key)
 {
    int i;
    char *str ;
str = (char*)malloc(strlen(s)*sizeof(char));
   for (i = 0; i < strlen(s); i++)
    {
        if (s[i] >= MIN_RANGE && s[i] <= MAX_RANGE)
            str[i] = s[i] - key;
        else
            str[i] = s[i];
    }
    str[i] = \'\\0\';
    return str;
 }
bool isspecial(char c, char spec[], int size)
 {
   
    int i = 0;
    bool found = false;
   for (i = 0; i < size; i++)
    {
        if (c == spec[i])
        {
            found = true;
        }
    }
return found;
}
----------------------------------------------------------------------
//main.cpp
#include<iostream>
 #include\"Feb_3_encryptPwd.h\"
 using namespace std;
int main()
 {
   
    char special[] = { \'%\', \'$\', \'%\', \'&\', \'!\', \'?\', \'@\' };
    int numSpecial = sizeof(special) / sizeof(char);
   
    //driver for isValidPassword
    //array of strings
    char s[4][12] = { \"@Jan12kl\", \"12Bhjk\", \"_6bH?jkl\", \"%1Bhtyjk12n\" };
    int ret;
    //check each string of password
    cout << \"Driver for isValidPassword\" << endl;
    for (int i = 0; i < 4; i++)
    {
        ret = isValidPassword(s[i], special, numSpecial);
        if (ret)
        {
            cout << s[i] << \" is valid password\" << endl;
        }
        else
            cout << s[i] << \" is not valid password\" << endl;
    }
 }
---------------------------------------------------------------------------------
//output for isValidPassword
Driver for isValidPassword
 @Jan12kl is valid password
 12Bhjk is not valid password
 _6bH?jkl is not valid password
 %1Bhtyjk12n is not valid password
---------------------------------------------------
//output for encrypt



