Password Generator
Quick Lowery Offices has had some issues with hacking recently, people are breaking into the companies system through employees having bad passwords. You must develop a program to generate new passwords for the users.
e.g. Thomas Lower was born on 22/10/2004, his favourite colour is indigo, his shoe size is 10 and he lives in Maidstone.
The program must take from the user:
- Their full name
- Their date of birth
- Their favourite colour
- Their shoe size
- Where they live
And the password must be developed using:
- The first letter of their first name
- The second letter of their surname
- The last 2 digits of their birth year
- The second and third letters of their favourite colour
- The first three letters of their street name
- Their shoe size
- The letters C++
Thomas’ Password will be To04ndMai10C++
#include <stdio.h>
#include <string.h>
int main() {
char fullName[100];
char dateOfBirth[20];
char favouriteColor[20];
float shoeSize;
char location[100];
// Taking input from the user
printf("Enter your full name: ");
fgets(fullName, sizeof(fullName), stdin);
fullName[strcspn(fullName, "\n")] = '\0'; // Remove newline character
printf("Enter your date of birth (DD/MM/YYYY): ");
scanf("%s", dateOfBirth);
printf("Enter your favourite colour: ");
scanf("%s", favouriteColor);
printf("Enter your shoe size: ");
scanf("%f", &shoeSize);
printf("Enter where you live: ");
scanf("%s", location);
// Generating password
char password[20];
sprintf(password, "%c%c%02d%c%c%c%.2f%s", fullName[0], fullName[strlen(fullName)-2],
((dateOfBirth[strlen(dateOfBirth)-2] - '0') * 10) + (dateOfBirth[strlen(dateOfBirth)-1] - '0'),
favouriteColor[1], favouriteColor[2], location[0], shoeSize, "C++");
// Outputting the password
printf("Your password is: %s\n", password);
return 0;
}