1245;lk2004-04-07 03:18:53
Introduction
There are three levels of security: security based on what you have (e.g. having 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 security 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, letters 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 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 (The date of birth will be in day, month and four digit year format. The date is assumed to be valid ). This assignment should develop your skills in problem solving, system design and basic programming.

You will start generating your password by performing some basic mathematical tasks on the day, month and year entered by the user.

The tasks you have to perform are:

A. Calculate and output the factorial of the month.

B. Calculate and output the number of the different prime factors of the year. A prime factor of n is a factor of n which is a prime number. A prime number is any integer greater than 1 and only divisible by itself and 1.

C. Calculate and output the largest prime factor of the year.

D. Calculate and output the greatest common divisor of the day and the year. The gcd of two integers a and b is the largest integer which divides both a and b.

Suppose that your birthday is 29/04/1981

You should have 24 for A (24 = 1*2*3*4)

2 for B (the factors of 1981 are 1, 7, 283 and 1981. The prime factors being 7 and 283)

283 for C

1 for D since the gcd of 29 and 1981 is 1



In this case you should have on the screen the following sample output:



Please enter your date of birth: 29 4 1981

24

2

283

1

Press any key to continue…


E. Calculate and output the squared digit length of the day.

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:

2^2 + 9^2 = 85

8^2 + 5^2 = 89

8^2 + 9^2 = 145

1^2 + 4^2 + 5^2 = 42

4^2 + 2^2 = 20

2^2 + 0^2 = 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 lecturers). 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).

Once these values (from A to E) 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. With the same example 29/04/1981 they are

2 4 2 2 8 3 1 6

We then break this up into pairs:

24 22 83 16

Note: If the number of digits is odd, then you should "even them up" by including the "single digit cross sum" of the year. So, for example, if we ended up with 7 or 9 digits rather than 8, we could take each digit of the year and add them, 1 + 9 + 7 + 3 = 20, the digits of which can be added together, 2 + 0 = 2, in order to give a single digit that can be placed at the end of the sequence to "even it up".

These pairs are then used to generate (upper case) characters: 00 corresponds 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 corresponding letter. So 34, for example, would be 34 mod 26 = 8 which corresponds to I.

In this case you should have on the screen the following sample output:



Please enter your date of birth: 29 4 1981

24

2

283

1

6

YWFQ

Press any key to continue…