security system project in c++
Hi, friends in this article we will learn some practical implementation of the c++ by doing some mini project in the c++ this project will be associate with login panel in c++. we will use the file in c++ to store our password. change our password. and if the password is correct then we will validate the user and enter the safe zone.
What is a project?
project is something that you create after learning some theoretical knowledge and implement some good things practical.
Why we should do a project in c++?
When we are learning a programming language not necessarily c++, but maybe python, java, or any other language we should do a project in them because the project helps us to find many new things in programming that others might know. and help us to implement our theoretical concept of programming in a practical way and create some great things. and the project did by you also ask by your interviewer at the time of your interview.
Why should we do the project regularly?
after reading the above question you know what is the importance of the project but when we do regular practice it will make our concept stronger and keep train our brain to think more in logic and coding.
There are some basic requirements in c++ for doing this particular project.
First You look at the code given below then I will demonstrate to you all the functionality of the project. so here is the source code.
Note: create a text file with named "file.txt" and put any 4 digits random number before starting this project this is very mandatory step don't remove that step.
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
int a;
string line,old,pass1,pass2,pass;
cout<<"******* SECURITY SYSTEM PROGRAM *******";
do{
cout<<endl<<endl<<"***************************************"<<endl;
cout<<"* 1 -> change the password *"<<endl;
cout<<"* 2 -> go to login panel to see data *"<<endl;
cout<<"* 3 -> quit the program *"<<endl;
cout<<"***************************************"<<endl<<endl;
cout<<"enter your choice :- ";
cin>>a;
switch(a)
{
case 1:
{
ifstream outf;
outf.open("file.txt");
cout<<"enter the old password :-";
cin>>old;
if (outf.is_open())
{
while(!outf.eof())
{
outf>>line;
if(old==line)
{
outf.close();
ofstream outf1;
outf1.open("file.txt");
if (outf1.is_open())
{
cout<<"enter your new password :-";
cin>>pass1;
cout<<"enter your password again :-";
cin>>pass2;
if(pass1==pass2)
{
outf1<<pass1;
cout<<"password change succesfully";
}
}
}
else
{
cout<<"please enter valid password";
}
}
}
break;
}
case 2:
{
ifstream outf2;
outf2.open("file.txt");
cout<<"please enter a password :-";
cin>>pass;
if (outf2.is_open())
{
while(!outf2.eof())
{
outf2>>line;
if(pass==line)
{
cout<<"acess granted";
}
else
{
cout<<"password is wrong"<<endl;
}
}
}
break;
}
case 3:
{
break;
}
default:
cout<<"enter valid choice";
}
}
while(a != 3);
return 0;
}
so you read that code if you understand the concept and logic behind that then that is well and good but if you don't understand the code then don't worry we will discuss what we did above two keep your eyes focus on what you will read next.
In the starting of the program, there are three choices
- Change the password:- in the section, we will change the password of our program using the file remember any website you change the password for that you are first to ask old password and then ask for new password and confirm the new password and if you old password match with your password in files and your new password and confirm new password is same then your new password is saved into the file where your old password is stored.
- Go to login panel to see data:- if the password entered by you is correct then you are allowed to go into the secret area where you are having the secret content.
- Quit the program:- in this program, you use an infinite while loop till the time you press 1 or 2 you again ask for a choice and when you choose the 3rd option your program will be terminated.
For getting this project you should have a great understanding of file and it's working in c++ without file it's very difficult to get this project so if you don't know anything about the file in c++. then go and learn about the file first.
Hope you like our this first project article on our website do follow our Facebook page we will update them regularly. so you get regular updates of the project and many concepts in c++ and java.
Thank you very much for reading this article and if you find this article meaningful then please share with your friends so that they can also learn from somethings. keep doing a project and always learning something from them.
And if you want to contact us you can use our contact form shown on the right side of the computer and at the bottom of the mobile phone you can write your message there and we will reply accordingly.
Read Some Other Post
If you want to write a post on our website then please check this article on How to do a guest post.
4 Comments
how could i create a file and where please answer me i am student
ReplyDeletemy gmail=APDILAHI116@GMAIL.COM
You can put those file in the same folder where the C++ have
ReplyDeletewhere is the file?
Deleteyou need to create a file as file.txt in same folder where you c++ program have the file
ReplyDelete