Skip to content

Commit

Permalink
password-read-write
Browse files Browse the repository at this point in the history
  • Loading branch information
maoguala committed Nov 20, 2024
0 parents commit f7a2492
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++.exe build active file",
"command": "C:\\msys64\\ucrt64\\bin\\g++.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
1 change: 1 addition & 0 deletions pass.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
errr
51 changes: 51 additions & 0 deletions pswd.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>

int main()
{
char k1,k2,k3,k4;
char c1,c2,c3,c4;
char sel;

FILE*fp;
fp=fopen(".\\pass.dat","r");
printf("選擇您的動作: (a.修改系統內建密碼) (b.測試輸入密碼),不分大小寫: ");
scanf("%c",&sel);
if(sel=='a'||sel=='A'){
printf("請輸入新密碼\n");
c1=getch();
printf("x");
c2=getch();
printf("x");
c3=getch();
printf("x");
c4=getch();
printf("x\n");
fp=fopen(".\\pass.dat","w");
fprintf(fp,"%c%c%c%c",c1,c2,c3,c4);
fclose(fp);
printf("密碼修改完成\n");
return 0;
}else if(sel=='b'||sel=='B'){
printf("請輸入密碼\n");
c1=getch();
printf("x");
c2=getch();
printf("x");
c3=getch();
printf("x");
c4=getch();
printf("x\n");
fp=fopen(".\\pass.dat","r");
fscanf(fp,"%c%c%c%c",&k1,&k2,&k3,&k4);
if(c1==k1&c2==k2&c3==k3&c4==k4){
printf("恭喜你,輸入正確\n");
}else{
printf("輸入錯誤,請重新輸入!\n");
}
fclose(fp);
return 0;

}
}
Binary file added pswd.exe
Binary file not shown.

0 comments on commit f7a2492

Please sign in to comment.