How to use crypt() to create encrypted password strings

[aliekens@bmt-pc04 personal]$ cat crypt.cpp
#define _XOPEN_SOURCE
#include <unistd.h>
#include <iostream>
int main( int argc, char* argv[] ) {
        if( argc < 3 )
                std::cout << "Usage: " << argv[ 0 ] << " key salt" << std::endl;
        else
                std::cout << crypt( argv[ 1 ], argv[ 2 ] ) << std::endl;
}
[aliekens@bmt-pc04 personal]$ g++ crypt.cpp -lcrypt -o crypt
[aliekens@bmt-pc04 personal]$ ./crypt blah ab
ab1O6rZcXQgWU

comments powered by Disqus