/*
Use the "crypt" function to encrypt the passward of the logining user
The Declaration of the function is:
Char * crypt (const char * Key, const char * salt );
Key: The passward to encrypt
Salt: Maid ([a-zA-Z0-9./]) Here we set "salt" the first and the last character
Of the AGRU key
Return Value: contain 13 characters including the first two character is the "salt" AGRU
2006-02-18-9: 40
*/
# DEFINE _ xopen_source
# Include <unistd. h>
# Include <stdio. h>
Char * encode (const char * passward)
{
Char Salt [3];
Char * result;
Int size = strlen (passward );
Salt [0] = passward [0];
Salt [1] = passward [size-1];
Salt [2] = '/0 ';
Result = crypt (passward, salt );
Printf ("% s/n", result );
Return result;
}
Int main ()
{
Char * Key = "whhit_liyanan_computer_science ";
Char * result;
Result = encode (key );
Printf ("the result of the encrypt is: % s/n", result );
Return 0;
}