/* (c) kreator '98 */ /* password generator.. */ #include #include #include #include #include #include void fatal(const char *mesg) { puts(mesg); exit(EXIT_FAILURE); } void help(const char *mesg) { printf( "upotreba: %s [opcije][modifikatori] opcije: -h pomoc -p paranoicni passwordi :) -n normalni passwordi (default) modifikatori: v velika slova m mala slova a velika i mala\n", mesg); exit(EXIT_SUCCESS); } int main(int argc, char *argv[]) { int c,duzina=8,i,tmp,flag=1,j,kompliciraj=0,mala=2; char string[1+8]; unsigned int seed; while ((c=getopt(argc,argv,"hp:n:")) != -1) { switch(c) { case 'h': help(argv[0]); break; case 'p': kompliciraj=1; switch(*optarg) { case 'v': mala=0; break; case 'm': mala=1; break; case 'a': mala=2; break; default: help(argv[0]); } break; case 'n': kompliciraj=0; switch(*optarg) { case 'v': mala=0; break; case 'm': mala=1; break; case 'a': mala=2; break; default: help(argv[0]); } break; default: help(argv[0]); } } seed=((unsigned)(time(NULL)+getpid())); srandom(seed); printf("%s (c) kreator, 1998\n", argv[0]); if (kompliciraj) puts("PAZI! paranoicni passwordi.."); printf("`sasvim' slucajni passwordi glase:\n"); for(j=0;j<10;++j) { for(i=0;i=33) && (tmp<=126)) { flag=0; if (mala==1) tmp=tolower(tmp); else if (!mala) tmp=toupper(tmp); string[i]=tmp; } /* [a-z] [A-Z] [0-9] */ else if ((!kompliciraj) && (((tmp>='a') && (tmp<='z')) || ((tmp>='A') && (tmp<='Z')) || ((tmp>='0') && (tmp<='9')))) { flag=0; if (mala==1) tmp=tolower(tmp); else if (!mala) tmp=toupper(tmp); string[i]=tmp; } } string[8]=0; printf(" %2d.\t%s\n",j+1, string); } puts("od navedenih passworda izaberite *jedan*!"); return(EXIT_SUCCESS); }