CString strSQL="SELECT * FROM people"
GetDlgItem(IDC_EDIT1)->GetWindowText(Name)
GetDlgItem(IDC_EDIT2)->GetWindowText(PassWord)
m_pRecordset->Open(_bstr_t(strSQL),m_pConnection.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText)
m_name=(char*)_bstr_t(m_pRecordset->GetCollect("Pname"))
m_no=(char*)_bstr_t(m_pRecordset->GetCollect("Pno"))
m_pRecordset->Close()
if(PassWord==m_no&&Name==m_name)
{
send()
CDialog::OnOK()
}
else
{
AfxMessageBox("用户名或密码错误"歼渗)
}
我的是Access数据库。不过原理槐宴一样的。 m_name和m_no你自己在代码里加上你自己的用户铅改银名和密码就可以了。
#include <stdio.h>顷猛#include <string.h>
#include <conio.h>
void main()
{
char ch
char str[19] = {'\0'}
int i = 0
printf("Please input pass word:")
while((ch = getch())!= '\r'册乎帆)
{
i++
if(i >州雹 18)
{
printf("\nThe password max length is 18")
break
}
printf("*")
str[i-1] = ch
}
if(strcmp(str,"123") == 0)
printf("\nRight")
else
printf("\nError")
printf("\nPress any key to Exit!")
getch()
}
上面的方法可以讲任何非回车符都作为一个密码字符。
比较完整的带菜单的,可以使用backspace删除输入字符的程序如下:
#include <iostream>
using namespace std
#include <string.h>
#include <conio.h>
#include <stdlib.h>
#include <windows.h>
const char* menu[3] = {" (0)Set password"," (1)Check password"," (2)Exit"}
char pwd[19] = "admin"
void Menu()
{
for(int j = 0j<3j++)
cout<<menu[j]<<endl
cout<<"Use up/down select item"<<endl
cout<<"select:"
}
void SetCursorPosition(int x,int y)
{
COORD coord = {x, y}
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord)
}
void SetMenu(unsigned int i)
{
int j = 0
for(j = 0j<3j++)
{
SetCursorPosition(0,j)
if(j == i)
cout<<"->"
else
cout<<" "
}
SetCursorPosition(7,j+1)
cout<<i
SetCursorPosition(7,j+1)
}
bool CheckPassword(char password[])
{
int i = 0
char ch
char str[19] = {'\0'}
bool r
system("cls")
cout<<"Please input password:"
while((ch = _getch())!= '\r')
{
if(ch == 8)
{
if(i != 0)
{
i--
str[i] = '\0'
system("cls")
cout<<"Please input password:"
for(int j = 0j<ij++)
cout<<"*"
}
continue
}
i++
if(i >18)
{
cout<<"\nThe password max length is 18"
break
}
cout<<"*"
str[i-1] = ch
}
if(strcmp(str,password) == 0)
{
cout<<"\nRight"
r = true
}
else
{
cout<<"\nError"
r = false
}
cout<<"\nPress any key to Continue!"
_getch()
return r
}
void SetPassword()
{
int i = 0
char ch = '\0'
char str[19] = {'\0'}
if(CheckPassword(pwd) == TRUE)
{
system("cls")
cout<<"Please input new password:"
while((ch = _getch())!= '\r')
{
if(ch == 27)
{
cout<<"Password was not change."
break
}
if(ch == 8)
{
if(i >0)
{
i--
str[i] = '\0'
system("cls")
cout<<"Please input new password:"
for(int j = 0j<ij++)
cout<<"*"
}
continue
}
str[i] = ch
i++
cout<<"*"
}
strcpy_s(pwd,str)
cout<<endl<<"New password set OK!"
}
cout<<"Press anykey to continue."
_getch()
}
void main()
{
char ch
char str[19] = {'\0'}
int wch[2]
unsigned int menu = 0
while(true)
{
system("cls")
Menu()
SetMenu(menu)
while((wch[0] = _getch())!= '\r')
{
if(wch[0] == 224)
{
wch[1] = _getch()
if(wch[1] == 72)
{
if(menu == 0)
menu = 2
else
menu--
}
else if(wch[1] == 80)
{
if(menu == 2)
menu = 0
else
menu++
}
}
else
{
wch[0] = wch[0] - '0'
if(wch[0]>=0 &&wch[0] <3)
menu = wch[0]
}
SetMenu(menu)
}
switch(menu)
{
case 2:
exit(0)
break
case 1:
CheckPassword(pwd)
break
case 0:
SetPassword()
break
}
}
}
有种方法,可以试试:
先保存文件夹迅瞎键的文件链表信息(类似于一颗树),然后把所有的文件的内容加密后累计在一个文件中。解密的时候先读出文件链表信息,然后把文件内容解密后生成在各自的文件中。
这种方法对大文件夹来说虽然效率比较低,但是非常有效的。可以把加密后的文件夹进行任意拷贝移动,跟 *** 作系统没有多大的关系,也就是重新安装了 *** 作系统亩巧、格式化了系统盘,神启也可以正常使用。
许多文件夹加密的方法是只是对文件夹的属性进行处理了,一旦重新安装系统或拷贝在其他电脑上就不行了。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)