Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
430
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.48 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdint.h>
  3.  
  4. void print_key(uint8_t* key) {
  5. uint8_t i;
  6. for(i=0; i<16; ++i) {
  7. printf("%02x",key[i]);
  8. }
  9. putchar('\n');
  10.  
  11. }
  12.  
  13. int main(void) {
  14. FILE* rnd;
  15. uint8_t key[16];
  16. uint32_t count;
  17.  
  18. count = 0;
  19.  
  20. rnd = fopen("/dev/urandom", "rb");
  21.  
  22.  
  23.  
  24. while(1){
  25. uint8_t i;
  26.  
  27. fread(key, 1, 16, rnd);
  28.  
  29. print_key(key);
  30.  
  31. count += 16;
  32. if(count == 0xFFFFFFF0) {
  33. count = 0;
  34. fclose(rnd);
  35. rnd = fopen("/dev/urandom", "rb");
  36. }
  37. }
  38.  
  39. fclose(rnd);
  40.  
  41. return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement