# Challenge 1...



## LoneWolf071 (Nov 10, 2004)

OK... Make me a program in what ever language you want(make sure to leave the language name)...Leave comments in the code so i know what does which... PM me the code you make, and i will post the best code in 2 weeks. 

--The Challenge--
Make Me A program that will ask a user for a length of the password(up to 255 char.), then print out a Alpha-Numeric/Symbolic(EX:040\#xy\67&) password of said length, and it should give a choice of 10 passwords to choose. It must also make a file that wil store the password, unencrypted, incase the password is lost, etc....Most of all, have fun and be sure to make sure it is fool proof, and never underestimate the power of a fool.


----------



## elf (Jul 19, 2002)

So the password will be pre-assigned by us? and when the user enters a number for how many characters he wants to show?


----------



## LoneWolf071 (Nov 10, 2004)

make it show all of them... don't worry aout security.


----------



## Millsy (Feb 4, 2005)

a program for making passwords, and you don't worry about security


----------



## LoneWolf071 (Nov 10, 2004)

you know what i mean... about hiding the char on the screen...


----------



## ReeKorl (Mar 25, 2005)

Just a thought, if this is to be run from a command line, then it'll take up more than the available amount of space on the screen to output 2550 characters... (the max is 25 * 80 I think, making a max of 2000 chars)

Fancy limiting it to 155?


----------



## LoneWolf071 (Nov 10, 2004)

*Ex. Random Password Generator...*


```
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

char *rangeselect(void);
void passwordgen(char therange[], int lengthofpwd, int numofpwd);

int main()
{
	int enterd=0, lengthofpwd=8, numofpwd=10, choice;
	char *therange = "[email protected]#$%^&*-\/><}{[]._ ";
	
	printf("\n\n\n\n\n");
	printf("\t\t|/-\\|--Random Password Generation Program--|/-\\|\n");
	
	do{
		
		printf("Options:\n(1)-Choice Range For Password-(Default:A-Z, a-z, 0-9, Symbols)\n(2)-Enter Number Of Passwords You Want Generated-(Default:10)\n");
		printf("(3)-Enter The Length Of The Password-(Default:8)\n(4)-Generate Password-\n(5)Exit\n");
		printf("Selection:");
		scanf("%d", &enterd);
		//printf("%d", enterd);
		switch (enterd){
			case 1:
				therange = rangeselect();
				printf("%s\n", therange);
				break;
			case 2:
				printf("How Many Passwords Would You Like To Generate?\nEnter:");
				scanf("%d", &numofpwd);
				break;
			case 3:
				printf("Enter The Length Of The Password You Would Like\n");
				printf("Enter:");
				scanf("%d", &lengthofpwd);
				
				break;
			case 4:
				passwordgen(therange, lengthofpwd, numofpwd);
				break;
			default:
				break;
			};	
			printf("\n\n");
		}while(enterd != 5);
	return 0;
}

char *rangeselect(void)
{
	int chose;
	char *therange;
	
	printf("Which Password Type Would You Like?\n");
	printf("(1)A-Z, a-z\n");
	printf("(2)A-Z, a-z, 0-9\n");
	printf("(3)A-Z, a-z, 0-9, Symbols\n");
	printf("(4)0-9, Symbols\n");
	printf("(5)A-Z, a-z, Symbols\n");
	printf("Enter:");
	scanf("%d", &chose);
	
	switch(chose){
		case 1:
		therange = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
		break;
		
		case 2:
		therange = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
		break;
		
		case 3:
		therange = "[email protected]#$%^&*-\/><}{[]._ ";
		break;
		
		case 4:
		therange = "[email protected]#$%^&*-\/><}{[]._ ";
		break;
		
		case 5:
		therange = "[email protected]#$%^&*-\/><}{[]._ ";
		break;
		
		default:
		printf("You Forgot To Chose...\n");
	};
	return therange;
}

void passwordgen(char therange[],int passwdlen,int numofgen)
{
	
	char newpasswd[100][255], choice, filename[80];
	int i, j, k;
	FILE *fout;
	
	srand(time(NULL));//randomizes the numbers by time...
	
	printf("\n\n--=Setings=--\nPassword Length:%d\nThe Range:%s\nNumber Of Passwords To Generate:%d\n\n", passwdlen, therange, numofgen);
	printf("\t\t\t---Generating Passwords--\n\n");
	for(i = 0; i < numofgen; i++)
	{
		printf("%d.", i+1);
		for(j = 0; j < passwdlen;j++)
		{
			k = (rand()%strlen(therange));
			newpasswd[i][j] = therange[k];
			printf("%c", newpasswd[i][j]);			
		}
		printf("\n");
	}
	
	printf("Would You Like To Save Your Passwords To A File?\n");
	fflush(stdout);
	fflush(stdin);
	scanf("%c", &choice);
	
	if(choice == 'Y' || choice == 'y')
	{
		printf("What File Name Would You Like To Save It To?\n");
		scanf("%s", filename);
		fout = fopen(filename, "w");
		for(i = 0; i < numofgen; i++)
		{
			fputs(newpasswd[i], fout);
			fprintf(fout, "\n");
		}
		fclose(fout);
		printf("Done...\n");
	}
		
}
```


----------



## johnwill (Sep 26, 2002)

How much does this assignment pay? :smile:


----------



## LoneWolf071 (Nov 10, 2004)

oh let's think of a nice, round number...






































$0.00, there nice and round...


----------



## elf (Jul 19, 2002)

hehe, when I get my router back, or my new router (which I got for $9) I'll start working on it...My compiler is on my linux box and without them being networked I can't compile anything


----------

