#include #include #include #include using namespace std; //const string SALT {"$1$"}; //const string SALT {"$5$"}; //const string SALT {"$6$"}; //// the new version of crypt can require additional rounds of encryption const string SALT {"$6$rounds=10000$"}; // encryption of "bob" for salt $6$. const string BASE {"$6$$39NHYxvD3B.eNHoE5SL7He9jiWu/uJ84xTPPdpLvIvNFzKrAW/NQu2vkO1gi959rs1p2hBFtVBa9JjeIj6DTG/"}; const string PASSWORD {"bob"} ; const int ITERATIONS = 1000; int main() { string hash; int i; auto start = chrono::steady_clock::now(); for(i = 0; i < ITERATIONS ; ++ i) { hash = crypt(PASSWORD.c_str(), SALT.c_str()); hash == BASE; } auto end = chrono::steady_clock::now(); chrono::duration seconds = end-start; double iterationsPerSecond = static_cast(ITERATIONS) / static_cast(seconds.count()); cout << "\tThat took " << seconds.count() << " seconds for " << ITERATIONS << " passwords." << endl; cout << "\tOr " << iterationsPerSecond<< " passwords/second " << endl; return 0; }