2017-09-24 21:13:16 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
static const char hext[] = "0123456789ABCDEF";
|
2017-09-27 14:41:59 +02:00
|
|
|
static void printhex(const unsigned char *z,size_t l)
|
2017-09-24 21:13:16 +02:00
|
|
|
{
|
|
|
|
printf("[");
|
2017-09-27 14:41:59 +02:00
|
|
|
for (size_t i = 0;i < l;++i) {
|
|
|
|
printf("%c%c",hext[*z >> 4],hext[*z & 0xF]);
|
2017-09-24 21:13:16 +02:00
|
|
|
++z;
|
|
|
|
}
|
|
|
|
printf("]\n");
|
|
|
|
}
|
2017-10-22 07:07:45 +02:00
|
|
|
|
|
|
|
static void printbin(const unsigned char *z,size_t l)
|
|
|
|
{
|
|
|
|
printf("[");
|
|
|
|
for (size_t i = 0;i < l;++i) {
|
|
|
|
printf("%c%c%c%c%c%c%c%c",
|
|
|
|
hext[(*z >> 7) & 1],
|
|
|
|
hext[(*z >> 6) & 1],
|
|
|
|
hext[(*z >> 5) & 1],
|
|
|
|
hext[(*z >> 4) & 1],
|
|
|
|
hext[(*z >> 3) & 1],
|
|
|
|
hext[(*z >> 2) & 1],
|
|
|
|
hext[(*z >> 1) & 1],
|
|
|
|
hext[(*z ) & 1]);
|
|
|
|
++z;
|
|
|
|
}
|
|
|
|
printf("]\n");
|
|
|
|
}
|