mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
digest/digest_print: Use bytetohex() instead of snprintf()
This commit is contained in:
parent
32a0260291
commit
4fc08d8fc2
1 changed files with 3 additions and 1 deletions
|
@ -7,6 +7,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <sys/types.h> // for u_char
|
#include <sys/types.h> // for u_char
|
||||||
|
#include <zeek/util.h>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
|
@ -41,7 +42,8 @@ enum HashAlgorithm { Hash_MD5, Hash_SHA1, Hash_SHA224, Hash_SHA256, Hash_SHA384,
|
||||||
inline const char* digest_print(const u_char* digest, size_t n) {
|
inline const char* digest_print(const u_char* digest, size_t n) {
|
||||||
static char buf[ZEEK_DIGEST_PRINT_LENGTH];
|
static char buf[ZEEK_DIGEST_PRINT_LENGTH];
|
||||||
for ( size_t i = 0; i < n; ++i )
|
for ( size_t i = 0; i < n; ++i )
|
||||||
snprintf(buf + i * 2, 3, "%02x", digest[i]);
|
zeek::util::bytetohex(digest[i], &buf[i * 2]);
|
||||||
|
buf[2 * n] = '\0';
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue