Password Encryptor in C

Some time back, I had to implement a password encryption section in one of my bash programs. It seemed easy to use a C snippet rather than doing it in bash. This was something I got after searching a while.

#include stdlib.h
#include unistd.h
#include stdio.h
#include crack.h
#define DICTIONARY /usr/lib/cracklib_dict

int main(int argc, char *argv[]) {

char *password;
char *problem;

int status = 0;
printf(\nEnter an empty password or Ctrl-D to quit.\n);
while ((password = getpass(\nPassword: )) != NULL *password ) {
if ((problem = FascistCheck(password, DICTIONARY)) != NULL) {
printf(Bad password: %s.\n, problem);
status = 1;
else {
printf(Good password!\n);

Compile the code using the GNU C compiler.

# gcc filename.c -lcrack -o cracktest’

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.