JachuPL

Generator bazujący na /dev/urandom

Jun 21st, 2015
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.52 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <fcntl.h>
  3. #define BUFF_CAP 32
  4.  
  5. int main(int argc, char** argv)
  6. {
  7.     int dest = open("/dev/urandom", O_RDWR);
  8.     if (dest == -1)
  9.     {
  10.     perror("Wystapil blad");
  11.     return 1;
  12.     }
  13.    
  14.     char bytes[BUFF_CAP];
  15.     int bRead = 0;
  16.    
  17.     bRead = read(dest, bytes, BUFF_CAP);
  18.     int i;
  19.     for(i = 0; i < bRead; i++)
  20.     {
  21.     if ((int)bytes[i] < 0)
  22.         bytes[i] = (int)bytes[i] * -1;
  23.     bytes[i] = bytes[i]%30 + 1;
  24.     printf("%d ", bytes[i]);
  25.     }
  26.     printf("\n");
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment