util.c 428 B

123456789101112131415161718192021222324252627
  1. /*
  2. * (c) 2015-2017 Marcos Del Sol Vives
  3. * (c) 2016 javiMaD
  4. *
  5. * SPDX-License-Identifier: MIT
  6. */
  7. #include "util.h"
  8. #include <stdint.h>
  9. void printhex(void * data, size_t size) {
  10. size_t i;
  11. uint8_t * bytes = (uint8_t *) data;
  12. for (i = 0; i < size; i++) {
  13. if ((i % 16) > 0) {
  14. printf(" ");
  15. }
  16. printf("%02X", bytes[i]);
  17. if ((i % 16) == 15) {
  18. printf("\n");
  19. }
  20. }
  21. if ((i % 16) != 15) {
  22. printf("\n");
  23. }
  24. }