1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-25 23:21:54 +03:00

Merge data_blob_hex_string from Samba4.

Guenther
This commit is contained in:
Günther Deschner 2008-04-25 20:06:19 +02:00
parent fbd99071f9
commit 686d8939d9

View File

@ -156,3 +156,25 @@ DATA_BLOB data_blob_talloc_zero(TALLOC_CTX *mem_ctx, size_t length)
data_blob_clear(&blob); data_blob_clear(&blob);
return blob; return blob;
} }
/**
print the data_blob as hex string
**/
_PUBLIC_ char *data_blob_hex_string(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob)
{
int i;
char *hex_string;
hex_string = talloc_array(mem_ctx, char, (blob->length*2)+1);
if (!hex_string) {
return NULL;
}
for (i = 0; i < blob->length; i++)
slprintf(&hex_string[i*2], 3, "%02X", blob->data[i]);
hex_string[(blob->length*2)] = '\0';
return hex_string;
}