Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*************************************************************/
- /*Nome Prog: Generatore di Password */
- /*Questo semplice programma in C++, ti consente di generare */
- /*in modo autonomo password di tipo: */
- /*1-Alphanumerici (a-z,A-Z,0-9) */
- /*2-Solo Lettere */
- /*3-Solo Numeri */
- /*4-In base alle tue esigenze */
- /*Autore: florin88 */
- /*e-mail: ffinformaticus@gmail.com */
- /***********************************************************/
- #include<iostream>
- #include<stdlib.h>
- #include<time.h>
- #include<string.h>
- using namespace std;
- int main()
- {
- int length,x,str,j=0,answ;
- char pass[255],s[255],
- alphan[]="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
- alph[]="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
- num[]="0123456789";
- cout<<"##################################"<<endl;
- cout<<"Seleziona il tipo di password che vuoi generare: \n1-Alphanumerici (a-z,A-Z,0-9) \n2-Solo Lettere \n3-Solo Numeri \n4-Dai le tue direttive \nNUMERO della Funzione da utilizzare: ";
- cin>>answ;
- cout<<"##################################"<<endl;
- if(answ==4)
- {
- cout<<"Scrivi i caratteri che vuoi usare per la tua PASSWORD (senza lasciare spazi tra i caratteri): ";
- cin>>s;
- str=strlen(s);
- }
- cout<<"Quanto lunga deve essere la tua password? => ";
- cin>>length;
- srand(time(NULL));
- switch(answ)
- {
- case 1:{while(length--)
- {
- x=rand()%62;
- pass[j++]=alphan[x];
- }
- } break;
- case 2:{while(length--)
- {
- x=rand()%52;
- pass[j++]=alph[x];
- }
- } break;
- case 3:{while(length--)
- {
- x=rand()%10;
- pass[j++]=num[x];
- }
- } break;
- case 4:{while(length--)
- {
- x=rand()%str;
- pass[j++]=s[x];
- }
- } break;
- }
- cout<<"Ecco qui la tua PASSWORD: ";
- for(int i=0;i<j;i++)
- cout<<pass[i];
- cout<<endl;
- cout<<"##################################"<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement