Hi guys I need ur help to write this please
Introduction
There are three levels of security: security based on what you have (e.g. hav-
ing keys to a door), security based on what you are (e.g. your fingerprints
and DNA) and security based on what you know. The last level of secu-
rity is what we will explore here; specifically this assignment will be about
passwords.
The use of passwords for computer security is almost universal. Passwords
should be used as part of a complete security solution for a system, but very
often they are used as the only security for a system. While the idea of
passwords seems secure, they fail for a variety of reasons. One of the major
flaws passwords exhibit stems from the limitations of the password users. A
password, by its very nature, is completely useless if it is forgotten. The
user, therefore, will tend to choose a password that is easy to remember,
such as their birthday, their dogs name or their mother’s maiden name. A
little knowledge of the user, therefore, would enable someone to guess the
password and thus have access to all of the systems that password protects.
One solution to this is to generate random combinations of numbers, let-
ters and punctuation marks to be used as computer passwords. The problem
with these passwords is that they are very hard to remember and if they are
forgotten, it is impossible to reconstruct them. We can, however, use this
idea of a ’jumble’ of characters that is hard to guess in conjunction with a
password that is easy to remember. What we can do is encrypt the password.
To encrypt a password, you start with some easily remembered piece of
information (such as the user’s birthday or name) and you process it through
some sort of algorithm to change the form of that information. What results
1
is an encrypted password. This technique is flawed, but it does provide a
reasonable compromise since the user can always reconstruct their password
from known information if they happen to forget it.
Your Task
The goal of this assignment is to construct a C++ program that will produce
an encrypted password for the user given the user’s date of birth 1. This
assignment should develop your skills in problem solving, system design and
basic programming.
You will start generating your password by performing some basic math-
ematical tasks on the day, month and year entered by the user. The tasks
you should perform are:
A. Calculate the floor of the square root of the month2.
B Calculate the number of prime3 factors of the year.
C. Calculate the largest prime factor of the year.
D. Calculate the base 8 representation of the day.
E. Calculate the squared digit length of the day [See appendix].
For example, if the date entered were 29/07/1981, we would generate the
following results:
A. The square root if 7 is 2.645. . . and so the floor of this is 2.
B. The factors of year are 1, 7, 283 and 1981. Of these factors, 7 and 283
are both prime and so the number of prime factors is 2.
C. The largest prime factor is 283.
D. The base 8 representation of the day is 35.
E. The squared digit length of 29 is 6.
Once these values have been calculated, they can be used to generate the
password. What we do here is join the numbers up in the order of calculation
shown above:
1The date of birth will be in day, month and four digit year format
2The ”floor” of the square root is the largest whole number that is smaller than the
actual square root value
3prime number is any integer greater than 1 that is divisible by only itself and 1.
2 2 2 8 3 3 5 6
We then break this up into pairs:
22 28 33 56
[Note: If the number of digits is odd, then you should ”even them up” by
including a zero at the end].
These pairs are then used to generate (upper case) characters: 00 cor-
responds to A, 01 corresponds to B etc. If the number is greater than 25
(corresponding to Z), then we can mod the number by 26 to get a correspond-
ing letter. So 34, for example, would be 34 mod 25 = 8 which corresponds
to H.
The final password the generated would be:
WBGD
The Input
The input to this file will be the user’s date of birth in day, month, year
format. The input will be three integers. You may assume that the user will
enter a valid date (i.e. no punctuation, negative numbers, etc.).
The Output
The output from the program will be the results of the calculations discussed
above (steps A-E) as well as the final generated password. These numbers
should be displayed one per line. The final password should then be displayed
on the screen and your program should terminate.
Sample Input
Please enter your date of birth [dd mm yyyy]:29 7 1991
Sample Output
2
2
283
35
3
6
WBGD
Submission and Marking
You should name your file password.cpp.
Appendix
The following process determines the squared digit length of an integer. Take
any integer and add up the squares of its digits. This will give you another
integer. Repeat this procedure until the number you end up with is 1 or 4.
The number of times this process has to be repeated before it gets to 1 or 4
is the squared digit length. For example, if we start with 29, we get:
4
22 + 92 = 85
82 + 52 = 89
82 + 92 = 145
12 + 42 + 52 = 42
42 + 22 = 20
22 + 02 = 4
This process shows that the squared digit length of 29 is 6.
According to the experts, this process will always eventually reach either
1 or 4. These values are known as the attractors of this discrete dynamical
system (if you want to know more about this, ask your mathematics lectur-
ers). The squared digit length of 1 and 4 is zero, since we don’t actually have
to apply the process to them to reach the stopping condition (interestingly,
though, if we did apply the process, to 1, we would keep getting 1, but if we
applied it to 4, we would get a repeating sequence: 4, 16, 37, 58, 89, 145, 42,
20, 4, . . . ).
Ok, what do you have so far? If you haven't started then at least humor me by prompting the user for the data and reading their input into your program. Post the code back here with the code brackets '['code']' and '[/'code']' no quotes.
#include <iostream.h>
#include <cstdlib>
int main()
{
int mborn = 0;
int dayborn = 0;
char* first = " ";
char* ltnam = " ";
char midinit = ' ';
int yrborn = 0;
char yes = 'Y';
char no = 'N';
cout << "Enter you month of birth followed by the <ENTER> key:" << endl;
cin >> mborn;
cout << endl;
cout << "Enter your day of birth followed by the <ENTER> key: " << endl;
cin >> dayborn;
cout << endl;
cout << "Enter the year you were born followed by the <ENTER> key: " << endl;
cin >> yrborn;
cout << endl;
//output all information for approval
//need help keeps mixing first name and last name
cout << "You entered: " << endl;
cout << endl;
cout << first << endl;
cout << midinit << endl;
cout << ltnam << endl;
cout << mborn << endl;
cout << dayborn << endl;
cout << yrborn << endl;
cout << endl;
//confirm data
cout << "Is this correct? Y or N: " << endl;
cout << endl;
//create if and then statements so i can loop or not
if (yes)
{
cout << "Information confirmed" ;
cout << endl;
cout << "Now i have all the information i need." ;
}
elseif (no)
{
//cant find somewhere to loop to
goto <> ;
}
system("PAUSE")
return 0;
}
I don't like how you go about declaring "first" and "ltnam"; pointers and char arrays should not be used like this because you don't know how long the name will be so you run a chance of overwriting other code. Use strings instead: http://www.cplusplus.com/reference/string/string/
They are dynamically sized char arrays with some handy built in functions.
Drop line 53, that command is for old people. If "No" is selected then you should restart your loop, you don't need "goto" for that.
EDIT: I'll add more to this but you have some stuff to work on for now.
RE-EDIT: Your "if" statement won't work. You want to declare a bool type variable instead of char yes and char no. So something like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
//Delete lines 12 and 13 and do this
bool yn = false;
char answr;
//Then from line 15
while (!yn)
{
//...
//Lines 16 through 38
//...
cout << "Is this correct? Y or N: " << endl;
cin << answr;
if(toupper(answr) == 'Y')
{
cout << "Information confirmed\nNow I have all the information I need.\n";
yn = true;
}//End of if check
}//End of while loop
Thank you for your help, but I need a simple c++ code asking you about your date of your birth and it will generate the passwor. I got the example about what I'm talking about as .exe file. I'm wondering if you can give me your email and I will send it to you.
Thanks again I appreciate it..
Not as an exe. Sorry it's a pain in the butt changing my security settings for E mail. That post was meant to be sample code not the whole thing. Where you see the "//" and comments you are supposed to insert your own code.