aboutsummaryrefslogtreecommitdiff
path: root/tools/bin2hex.c
blob: f4f27458bf1eb1e0dc8b9b9702b30945fadc347e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <stdio.h>
#include <stdint.h>

int main(int argc, char **argv)
{
	int input;

	while (1) {
		input = getchar();

		if (input == EOF)
			break;

		printf("%02x", input);

		input = getchar();

		/* If we have odd number of bytes, pad with a NULL-byte. */
		if (input == EOF)
			input = 0;

		printf(" %02x\n", input);
	}

	return 0;
}