Lab9 - Computing and Information Sciences

advertisement
Lab 9
25 Points



C Programming for
Engineers
Due: 07/10/03 by midnight
Upload the .c files (do NOT submit any .out files) through the course web site.
Don’t forget to include a header at the top of your program that includes your information.
Name your labs EXACTLY as stated (all lowercase).
Lab91
(25 pts) Due to the growth in computer processing power and the confidential information that is
increasingly stored on computers in networks, cracking passwords has become a relatively easy
means for a hacker to acquire access to a system. The best way to protect against this is to create a
password that cannot be easily guessed by a hacker. The rand() function, used in conjunction with
the ASCII encoding of characters and type casting, allows us to create randomly-generated
passwords.
Character Value
0–9
a–z
Integer Value(ASCII value)
48 – 57
97 – 122
Write a program to generate a random alphanumeric, 8-character password. There should be, on
average, a ratio of 3 alphabetical characters for every 1 numeric characters. First, generate a random
number from 1 to 4.
If the number generated is a 1, then generate a numeric character 0-9.
If the number generated is 2-4, then generate an alphabetic character a-z and for each case, generate
a second random number in the range 48-57 or 97-122, respectively. Convert the integer generated
to an unsigned character.
Use a menu-driven program to generate three new passwords before exiting the program.
Your output should look similar to the following:
Do you wish to generate a new password (0 or 1)? 1
The new password is: xtttkuvj
Do you wish to generate a new password (0 or 1)? 1
The new password is: zq1kxems
Do you wish to generate a new password (0 or 1)? 1
The new password is: 7vh7ozs1
Do you wish to generate a new password (0 or 1)? 0
Download