Commit 53d91c5c authored by David Howells's avatar David Howells

Provide a binary to hex conversion function

Provide a function to convert a buffer of binary data into an unterminated
ascii hex string representation of that data.
Signed-off-by: default avatarDavid Howells <>
Acked-by: default avatarVivek Goyal <>
parent 1c9c115c
......@@ -500,6 +500,7 @@ static inline char * __deprecated pack_hex_byte(char *buf, u8 byte)
extern int hex_to_bin(char ch);
extern int __must_check hex2bin(u8 *dst, const char *src, size_t count);
extern char *bin2hex(char *dst, const void *src, size_t count);
int mac_pton(const char *s, u8 *mac);
......@@ -58,6 +58,22 @@ int hex2bin(u8 *dst, const char *src, size_t count)
* bin2hex - convert binary data to an ascii hexadecimal string
* @dst: ascii hexadecimal result
* @src: binary data
* @count: binary data length
char *bin2hex(char *dst, const void *src, size_t count)
const unsigned char *_src = src;
while (count--)
dst = hex_byte_pack(dst, *_src++);
return dst;
* hex_dump_to_buffer - convert a blob of data to "hex ASCII" in memory
* @buf: data blob to dump
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment