Coding Practice

Create a robust encryption system for generate password

Create a robust encryption system for generate password

Cyber Security is a key issue to protect our daily documents and applications stored and submitted in various platforms. Having a sturdy coding system to our generated positive identification is incredibly essential during this perspective. Your task is to make a pleasant and swish encrypted positive identification generator. Follow the directions fastidiously to make the positive identification generator. [5 Marks]

a. Take a 5 digit integer number from user. Use a function named Input_Number() to require the amount from user. If the amount isn't exactly of 5 digits, provides a warning message to user and exit/abort the program.

b. In case of a 5 digit number, pass each digit of the amount to a user defined function named character_extractor() which might return a character like a digit. Character related to each digit will be within the following sequence.


c
. Finally, pass your extracted characters during a user defined function named password_generator() to generate a 5 length password.

d. Show the password on screen.

Sample Output
9876543
Wrong input
Process returned 0 (0x0)   execution time : 14.036 s
Press any key to continue.
Source Code
#include <stdio.h>
 
int Input_Number()
{
    int number, i = 0;
 
    scanf("%d", &number);
    if(number < 9999 || number > 99999)
    {
        return 0;
    }
    else
    {
        return number;
    }
}
 
int character_extractor(int n)
{
    char i = 4, password[10], lastDigit;
 
    while(n >= 1)
    {
        lastDigit = n%10;
 
        if(lastDigit == 1)
        {
            password[i] = '#';
        }
        else if(lastDigit == 2)
        {
            password[i] = 'a';
        }
        else if(lastDigit == 3)
        {
            password[i] = 't';
        }
        else if(lastDigit == 4)
        {
            password[i] = 'j';
        }
        else if(lastDigit == 5)
        {
            password[i] = '9';
        }
        else if(lastDigit == 6)
        {
            password[i] = 'E';
        }
        else if(lastDigit == 7)
        {
            password[i] = '@';
        }
        else if(lastDigit == 8)
        {
            password[i] = '2';
        }
        else if(lastDigit == 9)
        {
            password[i] = 'F';
        }
        else if(lastDigit == 0)
        {
            password[i] = '?';
        }
        n = n/10;
        i--;
    }
    password[5] = '\0';
    printf("%s", password);
}
 
int main()
{
    int num;
    num = Input_Number();
    if(num == 0)
    {
        printf("Wrong input");
    }
    else
    {
        character_extractor(num);
    }
    return 0;
}
Sample Output-1
12345
#atj9
Process returned 0 (0x0)   execution time : 1.253 s
Press any key to continue.
                
Sample Output-2
91778
F#@@2
Process returned 0 (0x0)   execution time : 0.954 s
Press any key to continue.
                

No comments:

Post a Comment

Change Theme
X