mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-26 08:30:10 +01:00
util/mesa_sha1: add helper to reconvert sha1 hex strings
Converts the sha1 hex string representation back into its original more compact format. Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7725>
This commit is contained in:
parent
f88c13f26d
commit
1fabc4ecbe
2 changed files with 18 additions and 0 deletions
|
|
@ -49,3 +49,18 @@ _mesa_sha1_format(char *buf, const unsigned char *sha1)
|
|||
}
|
||||
buf[i] = '\0';
|
||||
}
|
||||
|
||||
/* Convert a hashs string hexidecimal representation into its more compact
|
||||
* form.
|
||||
*/
|
||||
void
|
||||
_mesa_sha1_hex_to_sha1(unsigned char *buf, const char *hex)
|
||||
{
|
||||
for (unsigned i = 0; i < 20; i++) {
|
||||
char tmp[3];
|
||||
tmp[0] = hex[i * 2];
|
||||
tmp[1] = hex[(i * 2) + 1];
|
||||
tmp[2] = '\0';
|
||||
buf[i] = strtol(tmp, NULL, 16);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,6 +54,9 @@ _mesa_sha1_final(struct mesa_sha1 *ctx, unsigned char result[20])
|
|||
void
|
||||
_mesa_sha1_format(char *buf, const unsigned char *sha1);
|
||||
|
||||
void
|
||||
_mesa_sha1_hex_to_sha1(unsigned char *buf, const char *hex);
|
||||
|
||||
void
|
||||
_mesa_sha1_compute(const void *data, size_t size, unsigned char result[20]);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue