random password generator
Hi, I am new to C and I am trying to write a program that will take in regular easy to remember passwords like 'JohnDoe' and encrypt them with random characters. This is what I have so far:
//passGen.c
Code:
#include <stdlib.h>
#include <stdio.h>
int main(void) {
int length = 8;
int r,i;
char c;
srand((unsigned int)time(0)); //Seed number for rand()
for(i=0;i<length; i++) {
r = rand() + 33;
c = (char)r;
printf("%c",c);
}
}
To run it in Linux/Unix do ./a.out or a.out passGen JohnDoe
The program works just the way I want it to, except I would like to narrow down the types of characters it uses. How would I modify it to only use 'normal' English letters (both upper and lower case,) numbers and only the additional characters ^, #, $ and @ for encryption? Also, I want to keep the integer length the same.