0% found this document useful (0 votes)
50 views20 pages

Omkar Bhikarje CPP

This program implements a basic login and registration system in C++. It allows users to register with validated information and login. It generates a verification code during registration to simulate email verification. The functions are organized to handle registration, validation, login and verification. Improvements like password hashing, user interface and account persistence could enhance the system.

Uploaded by

techstack901
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views20 pages

Omkar Bhikarje CPP

This program implements a basic login and registration system in C++. It allows users to register with validated information and login. It generates a verification code during registration to simulate email verification. The functions are organized to handle registration, validation, login and verification. Improvements like password hashing, user interface and account persistence could enhance the system.

Uploaded by

techstack901
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 20

A

PROJECT REPORT
ON

“Login and registration”

SUBMITTED TO

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION, MUMBAI


BY

MR. BHIKARJE OMKAR DNYANESHWAR

DIPLOMA IN
COMPUTER ENGINEERING

UNDER GUIDENCE OF
MISS. MESHRAM S.P.

DEPARTMENT of COMPUTER

A.C.S.’S
DIPLOMA IN ENGINEERING AND TECHNOLOGY, ASHTI
(2022-2023)
A.C.S.’S
DIPLOMA IN ENGINEERING AND TECHNOLOGY,

`A.C.S.’S. DIPLOMA IN ENGG & TECH, ASHTI Page | 1


ASHTI - 414203

CERTIFICATE
This is to Certify that the project report entitled
“Login and registration”
Submitted by
1. Mr. Bhikaraje Omkar Gorakh 2215020035
2. Mr. Mane Mahesh Prashant 2215020043
3. Mr. Ghanavat Abhay Dnyaneshwar 2215020036

In The Academic Year 2022-2023 In The Partial Fulfilment Of Third Semester Diploma in Computer
Engineering. It Is Certified That All Suggestion Indicated For Internal Assessment Have Been Incorporated In Report. The
Project Has Been Approved As It Satisfies The Academic Requirement In Respect Work Prescribed For The Said Degree

Prof. MESHRAM .S.P. Prof. Dhonde.S.A.


(Guide) (HOD)

SIGNATURE OF EXAMINER……………. Prof. Done.l.S.


(Principal)
INDEX

`A.C.S.’S. DIPLOMA IN ENGG & TECH, ASHTI Page | 2


Sr.No. Contents Pg.No.
Cover Page 1
Certificate 2
Index 3
1. Introduction 4
2. Working of functions in program 6
3. Work and working of program 8
4. Program 10
5. Output and use 16
6. Conclusion 19
Reference 20

1. Introduction: Login and Registration System in C++

`A.C.S.’S. DIPLOMA IN ENGG & TECH, ASHTI Page | 3


This C++ program serves as a basic login and registration system for a hypothetical website. The system
prompts users with a welcome message and gives them the option to register as new users or log in if
they already have an account.

Features:

1. User Registration:

- The program requests the user's first name, last name, email address, and password registration.

- Input validation ensures that the entered information meets certain criteria:

- First and last names must start with uppercase letters.

- Email addresses must follow a specific format and cannot start with a number or special character

- Passwords must meet length requirements and include at least one digit, one special character,
one uppercase letter, and one lowercase letter.

2. Verification Code:

- After successful registration, the program generates a verification code and prompts the user to enter it.

- This step simulates an email verification process often used to confirm user identities.

3. User Login:

- Users who already have accounts can choose to log in.

- The program requests the username and password for login.

Improvements and Considerations:

- The program emphasizes input validation to ensure that user-provided information is accurate
and secure.

- Code organization and modularization have been considered to enhance readability and

maintainability.

- The password complexity check can be further enhanced to enforce stronger security measures.

`A.C.S.’S. DIPLOMA IN ENGG & TECH, ASHTI Page | 4


- Error handling is implemented to address potential issues with user input.

Usage:

- Users interact with the program through the console, providing input as prompted.

- Successful registration and login messages are displayed upon completion of the respective
processes.

This program provides a foundational structure for a user authentication system and can serve as a
starting point for more advanced implementations with additional features and security measures.

2. Working of functions in program

Here is the functions and their working, which are going to use in our program:

`A.C.S.’S. DIPLOMA IN ENGG & TECH, ASHTI Page | 5


1. NewRegister() :

- This function handles the user registration process.


- It prompts the user to specify whether they are a new user or not.
- If the user is new, it collects and validates information such as first name, last name,
email, and password using helper functions (`validfirstname`, `validlastname`,
`validEmail`, `validpassword`).
- After successful registration, it calls the `verificationcode()` function for email
verification.
- If the user is not new, it prompts for login credentials.

2. validfirstname(string firstname) :

- Validates the user's first name.


- Checks if the first character is an uppercase letter.

3. validlastname(string lastname) :

- Validates the user's last name.


- Checks if the first character is an uppercase letter.

4. validEmail(string email) :

- Validates the user's email address.


- Checks if the email follows a specified format, contains one '@' and one '.', and does not start
with a number.

5. validpassword(string password) :

- Validates the user's password.


- Checks if the password meets length requirements and includes at least one digit, one special
character, one uppercase letter, and one lowercase letter.

6. verificationcode() :

- Simulates the email verification process.


- Generates a random verification code and displays it to the user.

`A.C.S.’S. DIPLOMA IN ENGG & TECH, ASHTI Page | 6


- Prompts the user to enter the verification code.
- If the entered code matches the generated one, it indicates that the user's account has been
verified and calls the `Login()` function.

7. Login() :

- Handles the user login process.


- Prompts the user to enter their username and password.
- Displays a success message upon successful login.

8. main() :

- The entry point of the program.


- Displays a welcome message and initiates the registration process by calling `NewRegister()`.

Overall Flow :

- The program starts by welcoming the user and calling `NewRegister()` to handle registration or
login.
- During registration, the program collects user information, validates it, and performs email
verification.
- If the user is not new, the program prompts for login credentials.
- Successful registration or login results in a success message.

Note :

- The code emphasizes input validation to ensure that user-provided information is accurate and
secure.
- Error handling is implemented for potential issues with user input.
- The program simulates an email verification process for educational purposes, and in a real-
world scenario, this would involve external email services.

This program provides a basic foundation for user authentication, and further enhancements can
be made to meet specific application requirements and security standards.

3. Work and working of program

`A.C.S.’S. DIPLOMA IN ENGG & TECH, ASHTI Page | 7


1. User Account Persistence:

- Implement a mechanism to store user account information persistently, such as in a file or a simple
database.

- Allow the program to retrieve and use this stored information during subsequent runs.

2. Password Hashing:

- Enhance the security of the user passwords by implementing password hashing.

- Choose a secure hashing algorithm (e.g., SHA-256) and modify the registration and login processes
accordingly.

3. User Interface (UI) Development :

- Create a simple graphical user interface (GUI) for the program using a C++ GUI library like Qt or
SFML.

- Design screens for registration, login, and account verification.

4. Multi-User Support :

- Extend the program to support multiple user accounts.

- Implement user authentication based on stored account information.

5. Account Locking and Unlocking :

- Introduce a mechanism to lock user accounts after a certain number of failed login attempts.

- Implement a process to unlock accounts, perhaps through an email verification link.

6. Email Sending Simulation :

- Simulate an actual email sending process by integrating an email sending library (or API) to send
verification codes.

- Explore libraries like SendGrid or use local SMTP servers for testing.

`A.C.S.’S. DIPLOMA IN ENGG & TECH, ASHTI Page | 8


7. Enhanced Password Policies :

- Strengthen password policies by implementing more advanced rules (e.g., password expiration,
complexity requirements).

- Allow users to change their passwords after initial registration.

8. Security Audit and Vulnerability Assessment :

- Conduct a security audit of the program to identify potential vulnerabilities.

- Implement fixes or improvements based on the audit results.

9. User Session Management :

- Implement a basic user session management system.

- Expire user sessions after a certain period of inactivity.

10. Two-Factor Authentication (2FA) :

- Integrate a simple two-factor authentication system.

- Explore methods like time-based one-time passwords (TOTP) for 2FA.

11. User Profile Management :

- Allow users to manage their profiles, such as updating personal information or changing profile
pictures.

- Implement a profile page where users can view and edit their details.

4. Program

`A.C.S.’S. DIPLOMA IN ENGG & TECH, ASHTI Page | 9


#include <bits/stdc++.h> // Login and Registration System
using namespace std;
void NewRegister();
bool validEmail(string);
bool validfirstname(string);
bool validlastname(string);
bool validpassword(string);
void verificationcode();
void Login();
int main()
{
// when the user opens the website
cout << "Hey.." << endl;
cout << "Welcome to our website!" << endl;
cout << "Let's begin the journey.." << endl
<< endl;

NewRegister();

return 0;
}
void NewRegister() // This function asks the user if he is a new user or have already an account
{

string NewRegister, Username, Password, firstname, lastname, email;

cout << "New register? \n(Note: if you are a new user type Yes, otherwise type No) \n";

cin >> NewRegister; // must be "yes" if he is a new user or "no" if he is not a new user
cin.ignore();

if (NewRegister == "Yes" || NewRegister == "yes" )


{
cout << "First name : "; // enter first name
cin >> firstname;
while (validfirstname(firstname) == false)
{
cout << "The first name is not valid please try again : " << endl;
cin >> firstname;
}
cout << endl
<< "Valid first name." << endl
<< endl;

cout << "Last name : "; // enter last name


cin >>lastname ;
while (validlastname(lastname) == false)
{

`A.C.S.’S. DIPLOMA IN ENGG & TECH, ASHTI Page | 10


cout << "The last name is not valid please try again : " << endl;
cin >> lastname;
}
cout << endl
<< "Valid last name." << endl
<< endl;

cout << "Email : "; // enter email


cin >> email;
while (validEmail(email) == false)
{
cout << "The email address is not valid please try again : " << endl;
cin >> email;
}
cout << endl
<< "Valid email address." << endl
<< endl;

cout << "Password : \n(Note: your password must be at least one digit,one special character, one uppercase letter, and
one lowercase letter) \n"; // enter password
cin >> Password;
while (validpassword(Password) == false)
{
cout << "The password is not valid please try again : " << endl;
cin >> Password;
}
cout << endl
<< "Valid password." << endl
<< endl;

cout << "Registration completed! \n" << endl;


verificationcode();
}
else if (NewRegister == "No" ||NewRegister == "no") // have already an account
{
string Username, Password;
cout << endl << " Log in " << endl<< endl;
cout << "Enter your username :" << endl;
getline(cin, Username);

cout << "Enter your password :" << endl;


cin >> Password;

cout << endl


<< "Login success!" << endl;
}
}
bool validfirstname(string firstname) // function to check the validity of the first name
{

`A.C.S.’S. DIPLOMA IN ENGG & TECH, ASHTI Page | 11


if (firstname[0] >= 'A' && firstname[0] <= 'Z')
return true;
else
return false;
}
bool validlastname(string lastname) // function to check the validity of the last name
{
if (lastname[0] >= 'A' && lastname[0] <= 'Z')
return true;

else
return false;

}
bool validEmail(string email) // function to check the validity of the email
{
int AT = -1, dot = -1; // variables to store the position of ( @ )and (dot)
int counterforAT = 0, counterforDot = 0; // check if there is more than one (@) or (dot)
if ((email[0] >= 'a' && email[0] <= 'z') || (email[0] >= 'A' && email[0] <= 'Z')) // if the email address start with
letter(valid )
{
for (int i = 0; i < email.length(); i++)
{
if (email[i] == '@') // If the character is '@'
{
AT = i;
++counterforAT;
}

else if (email[i] == '.') // If character is '.'


{
dot = i;
++counterforDot;
}
}
if (AT == -1 || dot == -1) // If (@) or (dot)is not present

return false;

if (AT > dot) // If (dot) is present before(@)

return false;

if (counterforDot > 1 || counterforAT > 1)


return false;

return !(dot >= (email.length() - 1));


}

`A.C.S.’S. DIPLOMA IN ENGG & TECH, ASHTI Page | 12


else if (email[0] >= '0' && email[0] <= '9') // if the email address start with number (not valid )
{
return false;
}
else // if the email address start with other symbols (not valid)
{
return false;
}
}
bool validpassword(string password) // function to check the validity of the password
{
int digit = 0, uppercase = 0, lowercase = 0, specialchar = 0; // counter to find if password contain at least one digit,one
special character, one uppercase letter, and one lowercase letter
if (password.length() >= 8 && password.length() <= 15)
{

if (password.find(" ") == -1)


{
for (int i = 0; i < password.length(); i++)
{
if (password[i] >= '0' && password[i] <= '9')
{
++digit;
}
else if (password[i] >= 'a' && password[i] <= 'z')
{
++lowercase;
}
else if (password[i] >= 'A' && password[i] <= 'Z')
{
++uppercase;
}
else if (password[i] == '@' || password[i] == '#' || password[i] == '_')
{
++specialchar;
}
}

if (digit == 0 || uppercase == 0 || lowercase == 0 || specialchar == 0)


{
return false;
}
else
{
return true;
}
}
else if (password.find(" ") != -1)
{

`A.C.S.’S. DIPLOMA IN ENGG & TECH, ASHTI Page | 13


return false;
}
}

cout << "Note : your password length less than 8 characters or more than 15 characters." << endl;
return false;
}
void verificationcode() // verifying account
{
int code ;

cout << "We have sent a verification code to your email to confirm your account." << endl
<< "Please check your email." << endl;

cout<<"Email message: Your verification code is ";


srand(time(0));

for (int i = 0; i <= 3; i++)


{
cout << rand() % 10 ;
}
cout<<"\n";

cout<<"Enter the verification code here : \n";


cin>>code;

cout << "Your account has been verified." << endl;


Login();
}
void Login()
{
string Username, Password;

cin.ignore();
cout << endl << " Log in " << endl<< endl;
cout << "Enter your username :" << endl;
getline(cin, Username);

cout << "Enter your password :" << endl;


cin >> Password;

cout << endl


<< "Login success!" << endl;
}

`A.C.S.’S. DIPLOMA IN ENGG & TECH, ASHTI Page | 14


5. Output and use

This is how we can use the login and registration program :

If you are new, then type Yes for new registration, or type No for Login existing account. In this case we
are going to type for create new account.

`A.C.S.’S. DIPLOMA IN ENGG & TECH, ASHTI Page | 15


Enter your first name.

Enter your last name.

Enter your email id.

`A.C.S.’S. DIPLOMA IN ENGG & TECH, ASHTI Page | 16


Enter strong passwords that has, at least one digit, one special character, one uppercase letter, and one
lowercase letter.

Enter verification code.

Now, you are Created a account, and good to go for login.

Just enter username and password and you’ll get successfully login.

`A.C.S.’S. DIPLOMA IN ENGG & TECH, ASHTI Page | 17


6. Conclusion

The C++ program exemplifies the core functionality of a login and


registration system, offering a hands-on exploration of fundamental concepts in
user authentication and data validation. The program's structure emphasizes
modularity, with distinct functions addressing specific aspects of the user
interaction process.

By incorporating stringent input validation checks, the program ensures the


accuracy and security of user-provided information during registration. The
simulated email verification process adds a layer of realism, mimicking a common
practice in online platforms to confirm user identities.

For learners seeking to expand this micro project, numerous avenues for growth
exist. These include implementing persistent user account storage, enhancing
password security through hashing algorithms, introducing graphical user

`A.C.S.’S. DIPLOMA IN ENGG & TECH, ASHTI Page | 18


interfaces, and exploring advanced security measures like two-factor
authentication.

Moreover, the code establishes a foundation for potential improvements in user


experience, such as multi-user support, account locking mechanisms, and
internationalization features. The program's versatility allows learners to tailor
their exploration based on individual interests and skill development goals.

As a comprehensive learning experience, this program not only introduces


practical coding skills but also encourages a deeper understanding of software
security principles. By extending and enhancing the project, learners can gain
valuable insights into real-world applications of user authentication systems and
bolster their proficiency in C++ programming. The journey doesn't end here; it
serves as a starting point for a continual exploration of software development and
cybersecurity.

 References
1) Figures are download from www.msbte.com
2) www.google.com
3) www.nationalgeographic.com
4) www.energyeduction.ca
5) For type this project we have use a MS-word
6) And we have complete these project under guidance of Miss. Meshram .S.P.

`A.C.S.’S. DIPLOMA IN ENGG & TECH, ASHTI Page | 19


`A.C.S.’S. DIPLOMA IN ENGG & TECH, ASHTI Page | 20

You might also like