#include #include // for crypt.h #include // note this must be linked with -lcrypt // see make file. using namespace std; void CryptWithReport(string password, string seed) { char * result; cout << "Crypting: " << password << endl; cout << "With seed: " << seed << endl; result = crypt (password.c_str(), seed.c_str()); cout << "Result: \"" << result << "\"" << endl;; cout << endl; return; } int main() { char * result; string tmp; string passwd; string salt = "ab"; passwd = getpass("What password will you use? => "); cout << endl; cout << "Ok, I'll use the password " << passwd << endl; cout << endl; CryptWithReport(passwd, salt); tmp = crypt(passwd.c_str(), salt.c_str()); CryptWithReport(passwd, tmp); CryptWithReport(passwd, "$6$abcdefg"); return 0; }