You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
690 B

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. #include <ctype.h>
  5. int run_passwortGenerator(){
  6. printf("\nPasswort Generator\n\n");
  7. char zeichen[] = "abcdefghijklmnopqrstuvwxyz0123456789!%&/()=?*#";
  8. while(1){
  9. int eing = 0;
  10. printf("Tippen Sie die gewuenschte Passwortlaenge ein, um ein neues zu generieren\noder '0' um das Programm zu beenden: ");
  11. scanf("%d", &eing);
  12. int tmp = 0;
  13. int GroSSklein = 0;
  14. if(eing == 0){return 0;}
  15. printf("\nIhr Passwort: ");
  16. srand(time(0));
  17. for(int i = 0; i < eing; i++)
  18. {
  19. tmp = rand()%46;
  20. GroSSklein = rand()%2;
  21. printf("%c", (tmp<26?(GroSSklein==0?toupper(zeichen[tmp]):zeichen[tmp]):zeichen[tmp]));
  22. }
  23. printf("\n");}
  24. return 0;
  25. }