mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core: C++-ify SHA1 interface
All callers of the SHA1 code are C++. Might just as well use a C++ like interface. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
729356e0b1
commit
21f68387ae
6 changed files with 71 additions and 78 deletions
|
@ -138,18 +138,14 @@ extern "C" int add_dive_site_to_table(struct dive_site *ds, struct dive_site_tab
|
|||
/* If the site doesn't yet have an UUID, create a new one.
|
||||
* Make this deterministic for testing. */
|
||||
if (!ds->uuid) {
|
||||
SHA_CTX ctx;
|
||||
uint32_t csum[5];
|
||||
|
||||
SHA1_Init(&ctx);
|
||||
SHA1 sha;
|
||||
if (ds->name)
|
||||
SHA1_Update(&ctx, ds->name, strlen(ds->name));
|
||||
sha.update(ds->name, strlen(ds->name));
|
||||
if (ds->description)
|
||||
SHA1_Update(&ctx, ds->description, strlen(ds->description));
|
||||
sha.update(ds->description, strlen(ds->description));
|
||||
if (ds->notes)
|
||||
SHA1_Update(&ctx, ds->notes, strlen(ds->notes));
|
||||
SHA1_Final((unsigned char *)csum, &ctx);
|
||||
ds->uuid = csum[0];
|
||||
sha.update(ds->notes, strlen(ds->notes));
|
||||
ds->uuid = sha.hash_uint32();
|
||||
}
|
||||
|
||||
/* Take care to never have the same uuid twice. This could happen on
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue