init
This commit is contained in:
45
src/libecrypt.c
Normal file
45
src/libecrypt.c
Normal file
@@ -0,0 +1,45 @@
|
||||
/* libecrypt - library for including ecrypt functions in programs */
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
void ecrypt(int N) {
|
||||
int c = 0;
|
||||
int randomizer = 0;
|
||||
|
||||
srand((unsigned int)(time(NULL)));
|
||||
|
||||
char numbers[] = "1234567890";
|
||||
char letter[] = "qwertyuiopasdfghjklzxcvbnm";
|
||||
char LETTER[] = "QWERTYUIOPASDFGHJKLZXCVBNM";
|
||||
char symbols[] = "!@#$%^&*?";
|
||||
char password[N];
|
||||
|
||||
randomizer = rand() % 4;
|
||||
|
||||
for (c = 0; c < N; c++) {
|
||||
switch (randomizer) {
|
||||
case 1:
|
||||
password[c] = numbers[rand() % 10];
|
||||
randomizer = rand() % 4;
|
||||
printf("%c", password[c]);
|
||||
break;
|
||||
case 2:
|
||||
password[c] = symbols[rand() % 8];
|
||||
randomizer = rand() % 4;
|
||||
printf("%c", password[c]);
|
||||
break;
|
||||
case 3:
|
||||
password[c] = LETTER[rand() % 26];
|
||||
randomizer = rand() % 4;
|
||||
printf("%c", password[c]);
|
||||
break;
|
||||
default:
|
||||
password[c] = letter[rand() % 26];
|
||||
randomizer = rand() % 4;
|
||||
printf("%c", password[c]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user