This commit is contained in:
2023-03-30 14:14:12 -04:00
commit e779d47a10
4 changed files with 78 additions and 0 deletions

45
src/libecrypt.c Normal file
View 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]);
}
}
}