c++密码验证程序
///////////////////////////////////////////////////////////
#include <iostream>
#include <conio.h>
#include <string.h>
#include <fstream>
//#include <windows.h>
using namespace std;
void display(); //主界面函数
void xuanze();  //选择函数
int read_file(); //读取密码文件
void write_file();//写入密码文件
void Create_mima(); //创建密码
void YanZheng_mima(); //验证密码
void Chang_mima();    //修改密码
void delete_mima();  //删除密码
//////////////////////////////////////////////////////////////////////////
void jiami_suanfa(char* str); //加密解密算法
char mimaStr[100];  //全局变量
//////////////////////////////////////////////////////////////////////////以上是函数的声明部分
//////////////////////////////////////////////////////////////////////////下面是函数的实现部分
void display() //主界面函数
{
全彩 列车到站之前无法停止 system("cls");
read_file();
cout<<"\t\t************************************************"<<endl;
cout<<"\t\t\t\t欢迎使密码验证系统"<<endl;
cout<<"\t\t************************************************"<<endl;
if(strlen(mimaStr)==0)cout<<"\t\t\t\t  [1]  创建密码"<<endl;
else cout<<"\t\t\t\t      创建密码"<<endl;                        //密码已经存在就不能创建了
cout<<"\t\t\t\t  [2]  验证密码"<<endl;
cout<<"\t\t\t\t  [3]  修改密码"<<endl;
cout<<"\t\t\t\t  [4]  删除密码"<<endl;
cout<<"\t\t\t\t  [5]  退出系统"<<endl;
cout<<"\t\t************************************************"<<endl;
一个小黑人 xuanze();
}
void xuanze()
{
cout<<"\t\t请输入你要进行的操作数: ";
char ch;
L: ch=getch();
if ((ch=='1' && strlen(mimaStr)==0) || ch=='2' || ch=='3' || ch=='4' || ch=='5')
{
  switch(ch)
  {
  case '1':Create_mima();
  break;
  case '2':YanZheng_mima();
  break;
  case '3':Chang_mima();
  break;
  case '4':delete_mima();
  break;
  case '5':exit(0);
  break;
猪肉丸子的做法  }
}
else goto L;
}
int read_file() //读取密码文件
{
L: ifstream infile("");
if (!infile)
{
  write_file();
  goto L;
}
else
  infile>>mimaStr;
return 1;
}
void write_file()//写入密码文件
{
ofstream outfile("");
if (!outfile)
{
  cout<<"can not open the file!"<<endl;
  return;
}
else
  outfile<<mimaStr;怎么做灯笼简单又漂亮
}
void jiami_suanfa(char* str) //加密解密算法
{
int len=strlen(str);
for (int i=0;i<len;i++)
  str[i]=str[i]^'g';
好听的快手昵称}
void Create_mima() //创建密码
{
system("cls");
char ch;
int i=0;
char str[100];  //确认密码存放处
cout<<"请输入新建密码,Enter结束(大于等于6位数): ";
ch=getch();
while (i<100)
{
  if (ch==13 && i>5)break;
  else if(ch==13)ch=getch();
  else
  {
  cout<<"*";
  mimaStr[i++]=ch;
  ch=getch();
  }
}
mimaStr[i]='\0';        //结束标志
i=0;
cout<<endl<<"请输入确认密码,Enter结束(大于等于6位数): ";        //第二次输入密码
ch=getch();
while (i<100)
{
  if (ch=='\r' && i>5)break;
  else if(ch=='\r')ch=getch();
  else
  {
  cout<<"*";
  str[i++]=ch;
  ch=getch();
  }
}
str[i]='\0';    //结束标志
if (strcmp(mimaStr,str)==0)
{
  jiami_suanfa(mimaStr);
  write_file();
  cout<<endl<<"创建密码成功!,任意键返回..."<<endl;
  ch=getch();
  display();
}
else
{
  cout<<"两次输入密码不一样,创建失败! 继续创建密码按Enter,任意键返回..."<<endl;
  ch=getch();
  if (ch=='\r')Create_mima();
  else display();
}
}
void YanZheng_mima() //验证密码
{
read_file();
system("cls");
char ch;
char str[100];
int i=0;
cout<<"请输入你要验证的密码,Enter结束: ";
ch=getch();
while (i<100)
{
  if (ch=='\r' && i>5)break;
  else if(ch=='\r')ch=getch();
  else
  {
  cout<<"*";
  str[i++]=ch;泼水节是哪个民族
  ch=getch();
  }
}
str[i]=0;
cout<<endl;
jiami_suanfa(mimaStr);    //解密
if (strcmp(str,mimaStr)==0)
{
  cout<<"恭喜!验证成功!任意键返回..."<<endl;
  ch=getch();
  display();
}
else
{
  cout<<"验证不成功!Enter继续验证,任意键返回..."<<endl;

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。