/* simple env for crypt */ /* only some parts are mine.. */ /* kreator, 1998 */ #include #include #include #include #include #include extern char *crypt (const char *key, const char *salt); int main(int argc, char *argv[]) { static char saltChars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./"; char salt[3], *plaintext; if (argc<2) { srandom((unsigned)(time(0)+getpid())); salt[0] = saltChars[random() % 64]; salt[1] = saltChars[random() % 64]; salt[2] = 0; } else { salt[0] = argv[1][0]; salt[1] = argv[1][1]; salt[2] = '\0'; if (!strchr(saltChars, salt[0]) || !strchr(saltChars, salt[1])) fprintf(stderr, "illegal salt %s\n", salt), exit(EXIT_FAILURE); } plaintext = getpass("plaintext: "); printf("crypted password: %s\n", crypt(plaintext, salt)); return(EXIT_SUCCESS); }