[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ale] FW: more info on crypt.






Below is code and output of 2 executions




Run 1:
You entered: password
It was encrypted to: ctmNrZ7a6zlUA
The correct password is: ctmNrZ7a6zlUA
Correct!


Run 2:
You entered: password12345
It was encrypted to: ctmNrZ7a6zlUA
The correct password is: ctmNrZ7a6zlUA
Correct! 


--------- test.c -----------------
#include <unistd.h>


#define PASSWORD "ctmNrZ7a6zlUA"



int
main(void)
{
?????????????? char password[32];
?????????????? char *encrypted;


?????????????? printf("password: ");
?????????????? scanf("%32s", password);


?????????????? encrypted = crypt(password, PASSWORD);


?????????????? // DEBUG
?????????????? printf("You entered: %s\n", password);
?????????????? printf("It was encrypted to: %s\n", encrypted);
?????????????? printf("The correct password is: %s\n", PASSWORD);
?????????????? // END DEBUG


?????????????? if (strcmp(encrypted, PASSWORD) == 0)
?????????????? ?????????????? printf("Correct!\n");
?????????????? else
?????????????? ?????????????? printf("Incorrect!\n");



?????????????? return 0;
}


??????????????