欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C++控制臺實現(xiàn)密碼管理系統(tǒng)

 更新時間:2020年11月27日 16:52:16   作者:keivin2006  
這篇文章主要為大家詳細介紹了C++控制臺實現(xiàn)密碼管理系統(tǒng),文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了C++控制臺實現(xiàn)密碼管理系統(tǒng)的具體代碼,供大家參考,具體內容如下

功能介紹:

1.怎么創(chuàng)建密碼,輸入兩次

2.怎么修改密碼

3.怎么刪除密碼

目錄

​1.主界面

2. 功能代碼

是不是有點意思,那還不ctrl-c ctrl-v   弄入你的IDE環(huán)境下,試下

// mima.cpp: 主項目文件。
 
#include "stdafx.h"
 
///
 
#include <iostream>
#include <conio.h>
#include <string.h>
#include <fstream>
//#include <windows.h>
using namespace std;
void display(); //主界面函數(shù)
void xuanze(); //選擇函數(shù)
 
int read_file(); //讀取密碼文件
void write_file();//寫入密碼文件
void Create_mima(); //創(chuàng)建密碼
void YanZheng_mima(); //驗證密碼
void Chang_mima(); //修改密碼
void delete_mima(); //刪除密碼
//
 
void jiami_suanfa(char* str); //加密解密算法
 
char mimaStr[100]; //全局變量
//以上是函數(shù)的聲明部分
 
//下面是函數(shù)的實現(xiàn)部分
 
void display() //主界面函數(shù)
{
 system("cls");
 read_file();
 cout<<"\t\t************************************************"<<endl;
 cout<<"\t\t\t\t歡迎使console密碼系統(tǒng)"<<endl;
 cout<<"\t\t************************************************"<<endl;
 if(strlen(mimaStr)==0)cout<<"\t\t\t\t [1] 創(chuàng)建密碼"<<endl;
 else cout<<"\t\t\t\t  創(chuàng)建密碼"<<endl;      //密碼已經存在就不能創(chuàng)建了
 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] 退出系統(tǒng)"<<endl;
 cout<<"\t\t************************************************"<<endl;
 xuanze();
}
 
void xuanze()
{
 cout<<"\t\t請輸入你要進行的操作數(shù): ";
 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("MiMa_record.txt");
 if (!infile)
 {
 write_file();
 goto L;
 } 
 else
 infile>>mimaStr;
 return 1;
}
 
void write_file()//寫入密碼文件
{
 ofstream outfile("MiMa_record.txt");
 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() //創(chuàng)建密碼
{
 system("cls");
 char ch;
 int i=0;
 char str[100]; //確認密碼存放處
 cout<<"請輸入新建密碼,按Enter結束(大于等于6位數(shù)): ";
 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位數(shù)): ";  //第二次輸入密碼
 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<<"創(chuàng)建密碼成功!,任意鍵返回..."<<endl;
 ch=getch();
 display();
 } 
 else
 {
 cout<<"兩次輸入密碼不一樣,創(chuàng)建失敗! 繼續(xù)創(chuàng)建密碼按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繼續(xù)驗證,任意鍵返回..."<<endl;
 ch=getch();
 if (ch=='\r')YanZheng_mima();
 else display();
 }
}
 
void Chang_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;
 i=0;
 jiami_suanfa(mimaStr); //解密
 if (strcmp(str,mimaStr)==0)
 {
 cout<<endl<<"請輸入修改密碼,按Enter結束(大于等于6位數(shù)): ";
 ch=getch();
 while (i<100)
 {
 if (ch=='\r' && i>5)break;
 else if(ch=='\r')ch=getch();
 else
 {
 cout<<"*";
 mimaStr[i++]=ch;
 ch=getch();
 }
 }
 mimaStr[i]='\0';  //結束標志
 i=0;
 cout<<endl<<"請輸入確認密碼,按Enter結束(大于等于6位數(shù)): ";  //第二次輸入密碼
 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<<endl<<"兩次輸入密碼不一樣,修改失敗! 繼續(xù)修改密碼按Enter,任意鍵返回..."<<endl;
 ch=getch();
 if (ch=='\r')Chang_mima();
 else display();
 }
 } 
 else
 {
 cout<<endl<<"輸入密碼不匹配!你不能修改該密碼!任意鍵返回..."<<endl;
 ch=getch();
 display();
 }
}
 
void delete_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;
 i=0;
 jiami_suanfa(mimaStr); //解密
 if (strcmp(str,mimaStr)==0)
 {
 cout<<"確定刪除請按'y'or'Y',任意鍵取消返回..."<<endl;
 ch=getch();
 if (ch=='y' || ch=='Y')
 {
 mimaStr[0]='\0';
 write_file();
 cout<<"刪除成功,任意鍵返回..."<<endl;
 ch=getch();
 display();
 }
 else display();
 }
 else
 {
 cout<<endl<<"輸入密碼不匹配!你不能刪除該密碼!任意鍵返回..."<<endl;
 ch=getch();
 display();
 }
}
 
//mian函數(shù)
void main()
{
 display();
}

是不是和給出的效果一致呢, 以上的密碼只是簡單的異或操作加密,你可以在這基礎上加入你的專業(yè)級的加密算法試試哈, 什么 des aes都可以哈!

關于管理系統(tǒng)的更多內容請點擊《管理系統(tǒng)專題》進行學習

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關文章

  • C++虛函數(shù)表的原理與使用解析

    C++虛函數(shù)表的原理與使用解析

    對C++?了解的人都應該知道虛函數(shù)(Virtual?Function)是通過一張?zhí)摵瘮?shù)表(Virtual?Table)來實現(xiàn)的。簡稱為V-Table。本文就將詳細講講虛函數(shù)表的原理與使用,需要的可以參考一下
    2022-04-04
  • C語言小游戲之小熊跳板功能的實現(xiàn)

    C語言小游戲之小熊跳板功能的實現(xiàn)

    這篇文章主要介紹了C語言小游戲之小熊跳板功能的實現(xiàn),本文通過實例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2020-12-12
  • C++的靜態(tài)聯(lián)編和動態(tài)聯(lián)編

    C++的靜態(tài)聯(lián)編和動態(tài)聯(lián)編

    本文闡述了靜態(tài)聯(lián)編和動態(tài)聯(lián)編的概念和區(qū)別,通過具體實例分析了實現(xiàn)動態(tài)聯(lián)編的條件,指出了虛函數(shù)是實現(xiàn)動態(tài)聯(lián)編的基礎。
    2016-03-03
  • C語言return知識點總結

    C語言return知識點總結

    在本篇文章里小編給大家整理的是關于C語言return知識點總結內容,需要的朋友們可以學習參考下。
    2020-02-02
  • C++插件化 NDD源碼的插件機制實現(xiàn)解析

    C++插件化 NDD源碼的插件機制實現(xiàn)解析

    這篇文章主要介紹了C++插件化 NDD源碼的插件機制實現(xiàn)解析,這里再介紹推薦下優(yōu)秀的國產軟件開源項目?NDD(notepad--),一個支持windows/linux/mac的文本編輯器,目標是要國產替換同類軟件,需要的朋友可以參考下
    2023-03-03
  • C語言判斷字符串長度的方法小結

    C語言判斷字符串長度的方法小結

    學過C/C++的人都知道,在C/C++中并沒有提供直接獲取數(shù)組長度的函數(shù),對于存放字符串的字符數(shù)組提供了一個strlen函數(shù)獲取其長度,那么對于其他類型的數(shù)組如何獲取他們的長度呢?本文給大家介紹了C語言判斷字符串長度的方法小結,需要的朋友可以參考下
    2024-08-08
  • C/C++編譯報錯printf was not declared in this scope問題及解決

    C/C++編譯報錯printf was not declared in 

    這篇文章主要介紹了C/C++編譯報錯printf was not declared in this scope問題及解決方案,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2023-08-08
  • C語言枚舉類型詳解

    C語言枚舉類型詳解

    這篇文章主要介紹了C語言枚舉類型詳解的相關資料,需要的朋友可以參考下
    2023-05-05
  • C語言編程時常犯十八個錯誤小結

    C語言編程時常犯十八個錯誤小結

    C語言的最大特點是:功能強、使用方便靈活。C編譯的程序對語法檢查并不象其它高級語言那么嚴格,這就給編程人員留下“靈活的余地”,但還是由于這個靈活給程序的調試帶來了許多不便,尤其對初學C語言的人來說,經常會出一些連自己都不知道錯在哪里的錯誤
    2013-07-07
  • C語言實現(xiàn)密碼強度檢測

    C語言實現(xiàn)密碼強度檢測

    這篇文章主要為大家詳細介紹了C語言實現(xiàn)密碼強度檢測,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2020-03-03

最新評論