using namespace std;
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE
#endif
#include int
main(int argc,char *argv[])
{
char password[100];
char confirm[100];
char *salt[] = {
"ab", "cd", "ef", "gh"
};
cout << "please input password:>";
cin >> password;
cout << "password:" << password << endl;
cout << "press "y" to confirm:>";
cin >> confirm;
if(confirm[0]=='y')
{
cout << "confirmed." << endl;
for(int i=0;i<4;i++)
{
char *ret = crypt(password,salt[i]);
cout << "password:" << i << " result=" << ret << endl;
}
}
else
{
cout << "cancelled." << endl;
}
return 0;
}
编译方法: g++ -o cvsuser cvsuser.cpp -lcrypt