Advertisement
Guest User

Untitled

a guest
Dec 16th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <openssl/rand.h>
  4.  
  5. int main(int argc, char **argv) {
  6.  
  7. FILE *fptr;
  8. fptr = fopen("key.txt", "w");
  9.  
  10. unsigned char key[16];
  11.  
  12. if (fptr == NULL) {
  13. printf("Error opening file");
  14. return EXIT_FAILURE;
  15. }
  16.  
  17. if (!RAND_bytes(key, sizeof key)) {
  18. return EXIT_FAILURE;
  19. }
  20.  
  21. fprintf(fptr, "%s", key);
  22. fclose(fptr);
  23.  
  24. // printf("%s", key)
  25.  
  26. return 0;
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement