/***************************************************************************** MakePassword v0.3 MakePassword genera una password lunga almeno 7 caratteri e contenente almeno una lettera maiuscola, una minuscola e un numero. La lunghezza massima della password è MAX. Copyright (C) 2003 - 2006 Plinio Gatto - pli@autistici.org This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ****************************************************************************/ #include #include #include #define MAX 20 //Lunghezza massima della password void Intro(); //Titolo int ChkPass(char pwd[MAX], int lg); //Controlla la password int ChkNum(char p[MAX], int len); //Controlla la presenza di numeri int ChkHigh(char p[MAX], int len); //Controlla la presenza di maiuscole int ChkLow(char p[MAX], int len); //Controlla la presenza di minuscole main() { int i=0,k=0,l=0; char chr[63],pass[MAX]; time_t t; Intro(); for(i=48;i<=57;i++,k++) chr[k]=i; //Indicizza da '0' a '9' for(i=65;i<=90;i++,k++) chr[k]=i; //Indicizza da 'A' a 'Z' for(i=97;i<=122;i++,k++) chr[k]=i; //Indicizza da 'a' a 'z' do{ printf("\nInserire la lunghezza desiderata: "); scanf("%d",&l); if (l<7) printf("La password deve avere almeno 7 caratteri...\n"); if (l>20) printf("Questo programma genera password fino a 20 caratteri...\n"); }while ((l<7)||(l>20)); do{ srand((unsigned)time(&t)); //Genera il seme for(i=0;i=48) && (p[j]<=57)) return 1; return 0; } int ChkHigh(char p[MAX], int len) { int j=0; for(j=0;j=65) && (p[j]<=90)) return 1; return 0; } int ChkLow(char p[MAX], int len) { int j=0; for(j=0;j=97) && (p[j]<=122)) return 1; return 0; }