Add and use ot_checksum_bytes helper

This removes some duplicated code (and will be use even more later).
This commit is contained in:
Alexander Larsson committed 2020-09-11 12:00:05 +02:00
1 parent dddb449d2c
commit 32014d99e6
3 files changed
+14 -4

No files matched your search

+10
View File
@@ -275,3 +275,13 @@ ot_checksum_file_at (int dfd,
ot_checksum_get_hexdigest (&checksum, hexdigest, sizeof (hexdigest));
return g_strdup (hexdigest);
}
void
ot_checksum_bytes (GBytes *data,
guint8 out_digest[_OSTREE_SHA256_DIGEST_LEN])
{
g_auto(OtChecksum) hasher = { 0, };
ot_checksum_init (&hasher);
ot_checksum_update_bytes (&hasher, data);
ot_checksum_get_digest (&hasher, out_digest, _OSTREE_SHA256_DIGEST_LEN);
}
+3
View File
@@ -96,4 +96,7 @@ char * ot_checksum_file_at (int dfd,
GCancellable *cancellable,
GError **error);
void ot_checksum_bytes (GBytes *data,
guint8 out_digest[_OSTREE_SHA256_DIGEST_LEN]);
G_END_DECLS