Skip to content

Instantly share code, notes, and snippets.

@AlexeyTolstopyatov
Created July 26, 2024 06:16
Show Gist options
  • Save AlexeyTolstopyatov/ef1043c8b06404c271098c09676cc50b to your computer and use it in GitHub Desktop.
Save AlexeyTolstopyatov/ef1043c8b06404c271098c09676cc50b to your computer and use it in GitHub Desktop.
Маленький генератор паролей на Си.
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#define MINC_ASCII 0x21 /* Нижняя граница ASCII таблицы */
#define MAXC_ASCII 0x7a /* Верхняя граница ASCII таблицы */
int main(int argc, char *argv[]) {
srand((unsigned int)time(0));
if (argc < 2) {
printf("./pwgen [length]\n");
return -1;
}
for (int t = 0; t < atoi(argv[1]); t++) {
printf("%c", rand() % (MAXC_ASCII - MINC_ASCII) + MINC_ASCII);
}
printf("\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment