Digests

Digests — Content digests.

Synopsis

typedef             librdf_digest;
typedef             librdf_digest_factory;
librdf_digest *     librdf_new_digest                   (librdf_world *world,
                                                         const char *name);
void                librdf_free_digest                  (librdf_digest *digest);
void                librdf_digest_init                  (librdf_digest *digest);
void                librdf_digest_update                (librdf_digest *digest,
                                                         const unsigned char *buf,
                                                         size_t length);
void                librdf_digest_update_string         (librdf_digest *digest,
                                                         const unsigned char *string);
void                librdf_digest_final                 (librdf_digest *digest);
void *              librdf_digest_get_digest            (librdf_digest *digest);
size_t              librdf_digest_get_digest_length     (librdf_digest *digest);
char *              librdf_digest_to_string             (librdf_digest *digest);
void                librdf_digest_print                 (librdf_digest *digest,
                                                         FILE *fh);

Description

Create a message digest over a block of data. Includes implementations of MD5, RMD160 and SHA1.

Details

librdf_digest

typedef struct librdf_digest_s librdf_digest;

Redland content digest class.


librdf_digest_factory

typedef struct librdf_digest_factory_s librdf_digest_factory;

Redland digest factory class.


librdf_new_digest ()

librdf_digest *     librdf_new_digest                   (librdf_world *world,
                                                         const char *name);

Constructor - create a new librdf_digest object.

After construction, data should be added to the digest using librdf_digest_update or librdf_digest_update_string with librdf_digest_final to signify finishing. Then the digest value can be returned directly with librdf_digest_get_digest of librdf_digest_get_digest_length bytes or as a hex encoded string with librdf_digest_to_string. The digest can be re-initialised for new data with librdf_digest_init.

world :

redland world object

name :

the digest name to use to create this digest

Returns :

new librdf_digest object or NULL

librdf_free_digest ()

void                librdf_free_digest                  (librdf_digest *digest);

Destructor - destroy a librdf_digest object.

digest :

the digest

librdf_digest_init ()

void                librdf_digest_init                  (librdf_digest *digest);

(Re)initialise the librdf_digest object.

This is automatically called on construction but can be used to re-initialise the digest to the initial state for digesting new data.

digest :

the digest

librdf_digest_update ()

void                librdf_digest_update                (librdf_digest *digest,
                                                         const unsigned char *buf,
                                                         size_t length);

Add more data to the librdf_digest object.

digest :

the digest

buf :

the data buffer

length :

the length of the data

librdf_digest_update_string ()

void                librdf_digest_update_string         (librdf_digest *digest,
                                                         const unsigned char *string);

Add a string to the librdf_digest object.

digest :

the digest

string :

string to add

librdf_digest_final ()

void                librdf_digest_final                 (librdf_digest *digest);

Finish the digesting of data.

The digest can now be returned via librdf_digest_get_digest().

digest :

the digest

librdf_digest_get_digest ()

void *              librdf_digest_get_digest            (librdf_digest *digest);

Get the calculated digested value.

digest :

the digest

Returns :

pointer to the memory containing the digest. It will be librdf_digest_get_digest_length bytes in length.

librdf_digest_get_digest_length ()

size_t              librdf_digest_get_digest_length     (librdf_digest *digest);

Get length of the calculated digested.

digest :

the digest

Returns :

size of the digest in bytes

librdf_digest_to_string ()

char *              librdf_digest_to_string             (librdf_digest *digest);

Get a string representation of the digest object.

digest :

the digest

Returns :

a newly allocated string that represents the digest. This must be released by the caller using librdf_free_memory().

librdf_digest_print ()

void                librdf_digest_print                 (librdf_digest *digest,
                                                         FILE *fh);

Print the digest to a FILE handle.

digest :

the digest

fh :

file handle


Navigation: Redland Home Page

Copyright 2000-2023 Dave Beckett