#include <stdio.h> #include <stdlib.h> #include <time.h> static char xtea_key[17]; static const int XTEA_KEY_SIZE = 16; /* bytes */ static const int XTEA_KEY_RANGE = 58; /* ASCII letters*/ void gen_xtea_key(void) { int i; srand(time(NULL)); for (i = 0; i < XTEA_KEY_SIZE; i++) { if (i < XTEA_KEY_SIZE) xtea_key[i] = rand() % XTEA_KEY_RANGE + 'A'; else xtea_key[i] = 0; printf("c = %c, d = %u\n", xtea_key[i], xtea_key[i]); } } int main() { gen_xtea_key(); printf("key = %s\n", xtea_key); return 0; }
Standard input is empty
c = T, d = 84 c = A, d = 65 c = F, d = 70 c = t, d = 116 c = g, d = 103 c = y, d = 121 c = W, d = 87 c = ^, d = 94 c = D, d = 68 c = p, d = 112 c = S, d = 83 c = G, d = 71 c = a, d = 97 c = F, d = 70 c = x, d = 120 c = h, d = 104 key = TAFtgyW^DpSGaFxh