Sane C++ Libraries
C++ Platform Abstraction Libraries
sc_hashing

C bindings for Hashing library. More...

Classes

struct  sc_hashing_t
 Opaque object holding state of hashing. More...
 
struct  sc_hashing_result_t
 Hash result. More...
 
struct  sc_hashing_span_t
 Just a generic data span. More...
 

Macros

#define SANE_CPP_NO_DISCARD   __attribute__((warn_unused_result))
 

Enumerations

enum  sc_hashing_type {
  SC_HASHING_TYPE_MD5 ,
  SC_HASHING_TYPE_SHA1 ,
  SC_HASHING_TYPE_SHA256
}
 Type of hashing algorithm to use. More...
 

Functions

SANE_CPP_NO_DISCARD bool sc_hashing_init (sc_hashing_t *hashing, sc_hashing_type type)
 Initializes OS objects to compute hash (call sc_hashing_close when done). More...
 
void sc_hashing_close (sc_hashing_t *hashing)
 Releases os resources allocated by sc_hashing_init. More...
 
SANE_CPP_NO_DISCARD bool sc_hashing_add (sc_hashing_t *hashing, sc_hashing_span_t span)
 Add data to hash computation. Can be called multiple times to hash data iteratively. More...
 
SANE_CPP_NO_DISCARD bool sc_hashing_get (sc_hashing_t *hashing, sc_hashing_result_t *result)
 Obtain the actual hash of data added through sc_hashing_add. More...
 

Detailed Description

C bindings for Hashing library.

Sample usage:

bool res;
res = sc_hashing_init(&ctx, type);
res = sc_hashing_add(&ctx, (sc_hashing_span_t){.data = "test", .length = strlen("test")});
res = sc_hashing_add(&ctx, (sc_hashing_span_t){.data = "data", .length = strlen("data")});
sc_hashing_get(&ctx, &result);
//... use result.hash
SANE_CPP_NO_DISCARD bool sc_hashing_get(sc_hashing_t *hashing, sc_hashing_result_t *result)
Obtain the actual hash of data added through sc_hashing_add.
void sc_hashing_close(sc_hashing_t *hashing)
Releases os resources allocated by sc_hashing_init.
SANE_CPP_NO_DISCARD bool sc_hashing_init(sc_hashing_t *hashing, sc_hashing_type type)
Initializes OS objects to compute hash (call sc_hashing_close when done).
SANE_CPP_NO_DISCARD bool sc_hashing_add(sc_hashing_t *hashing, sc_hashing_span_t span)
Add data to hash computation. Can be called multiple times to hash data iteratively.
Hash result.
Definition: sc_hashing.h:60
Just a generic data span.
Definition: sc_hashing.h:67
Opaque object holding state of hashing.
Definition: sc_hashing.h:54

Enumeration Type Documentation

◆ sc_hashing_type

#include <sc_hashing.h>

Type of hashing algorithm to use.

Enumerator
SC_HASHING_TYPE_MD5 

Computes MD5 Hash.

SC_HASHING_TYPE_SHA1 

Computes SHA1 Hash.

SC_HASHING_TYPE_SHA256 

Computes SHA256 Hash.

Function Documentation

◆ sc_hashing_add()

SANE_CPP_NO_DISCARD bool sc_hashing_add ( sc_hashing_t hashing,
sc_hashing_span_t  span 
)

#include <sc_hashing.h>

Add data to hash computation. Can be called multiple times to hash data iteratively.

◆ sc_hashing_close()

void sc_hashing_close ( sc_hashing_t hashing)

#include <sc_hashing.h>

Releases os resources allocated by sc_hashing_init.

◆ sc_hashing_get()

SANE_CPP_NO_DISCARD bool sc_hashing_get ( sc_hashing_t hashing,
sc_hashing_result_t result 
)

#include <sc_hashing.h>

Obtain the actual hash of data added through sc_hashing_add.

◆ sc_hashing_init()

SANE_CPP_NO_DISCARD bool sc_hashing_init ( sc_hashing_t hashing,
sc_hashing_type  type 
)

#include <sc_hashing.h>

Initializes OS objects to compute hash (call sc_hashing_close when done).