-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakekey.c
More file actions
36 lines (32 loc) · 687 Bytes
/
makekey.c
File metadata and controls
36 lines (32 loc) · 687 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include "md5.h"
#include "license_keys.h"
#define KEYLEN 8
char *alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
main ()
{
char inbuf[33];
int i;
time_t now;
MD5_CTX ctx;
srand48 (getpid () ^ time (&now));
inbuf[KEYLEN] = 0;
for (i = 0; i < KEYLEN; i++)
{
inbuf[i] = alpha[lrand48() % strlen(alpha)];
}
MD5Init (&ctx);
MD5Update (&ctx, KEY1, strlen(KEY1));
MD5Update (&ctx, inbuf, strlen(inbuf));
MD5Update (&ctx, KEY2, strlen(KEY2));
MD5Final (&ctx);
fprintf (stdout, "%s ", inbuf);
for (i = 0; i < 8; i++)
{
fprintf (stdout, "%02X", ctx.digest[i]);
}
fprintf (stdout, "\n");
}