classCrypt.cpp

URL: https://mirkwood.cs.edinboro.edu/~bennett/class/cmac2000/spring2026/notes/two/code/classCrypt.cpp
 
#include <iostream>
#include <unistd.h>

using namespace std;

void CryptIt(string password, string salt);

int main() {
    string password {"hello"};
    string salt{"ab"};

    CryptIt(password, salt);
    CryptIt(password, salt);
    CryptIt("hello", "ac");
    CryptIt("hello", "acb");
    CryptIt("hello", "$1$acb$");
    CryptIt("hello", "$1$acbd$");
    CryptIt("hello", "$1$acbdefghijklmnopqrstuvwxyz$");
    CryptIt("hello", "$5$acbdefghijklmnopqrstuvwxyz$");
    CryptIt("hello", "$6$acbdefghijklmnopqrstuvwxyz$");
    CryptIt("hello", "$6$rounds=50001$acbdefghijklmnopqrstuvwxyz$");
    CryptIt("hello", "$6$rounds=50002$acbdefghijklmnopqrstuvwxyz$");
    //CryptIt("Hello", "ab");
    //CryptIt("hell0", "ab");
    //CryptIt("helo", "ab");

    return 0;
}

void CryptIt(string password, string salt) {
    cout << "The crypt of \"" << password << "\" with salt \"" 
         << salt << "\" is \"" << crypt(password.c_str(), salt.c_str())
         << "\"" << endl;
    cout << endl;
}