/* * crypt.c - return a crypted string * (C) Michele Andreoli */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if defined (__GNU_LIBRARY__) && __GNU_LIBRARY__ > 1 #include #endif #define ascii_to_bin(c) ((c)>='a'?(c-59):(c)>='A'?((c)-53):(c)-'.') #define bin_to_ascii(c) ((c)>=38?((c)-38+'a'):(c)>=12?((c)-12+'A'):(c)+'.') int main(argc, argv) int argc; char *argv[]; { struct passwd *pe; uid_t gotuid = getuid(); char *pwdstr = NULL, *cryptstr, *oldstr; char pwdstr1[10]; char *user; time_t tm; char salt[2]; pwdstr=argv[1]; if ( pwdstr==NULL ) { fprintf(stderr,"Syntax: crypt string\n"); exit (1); } time(&tm); tm ^= getpid(); salt[0] = bin_to_ascii(tm & 0x3f); salt[1] = bin_to_ascii((tm >> 6) & 0x3f); cryptstr = crypt(pwdstr, salt); printf("%s", cryptstr); }