fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4.  
  5. static const int XTEA_KEY_SIZE = 17; /* bytes */
  6. static const int XTEA_KEY_RANGE = 58; /* ASCII letters*/
  7. static char xtea_key[XTEA_KEY_SIZE];
  8.  
  9. void gen_xtea_key(void)
  10. {
  11. int i;
  12.  
  13. srand(time(NULL));
  14. for (i = 0; i < XTEA_KEY_SIZE; i++)
  15. {
  16. if (i < XTEA_KEY_SIZE - 1) {
  17. xtea_key[i] = rand() % XTEA_KEY_RANGE + 'A';
  18. } else {
  19. printf("xtea_key[i] = 0;\n");
  20. xtea_key[i] = 0;
  21. }
  22. printf("c = %c, d = %u\n", xtea_key[i], xtea_key[i]);
  23. }
  24. }
  25.  
  26. int main() {
  27. gen_xtea_key();
  28. printf("key = %s\n", xtea_key);
  29. return 0;
  30. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
c = [, d = 91
c = N, d = 78
c = N, d = 78
c = r, d = 114
c = H, d = 72
c = K, d = 75
c = J, d = 74
c = ^, d = 94
c = h, d = 104
c = C, d = 67
c = l, d = 108
c = q, d = 113
c = V, d = 86
c = ^, d = 94
c = r, d = 114
c = e, d = 101
xtea_key[i] = 0;
c = , d = 0
key = [NNrHKJ^hClqV^re