The required constant definitions are as follows:
#define MODULE_NAME MD2 /* Name of algorithm */ #define DIGEST_SIZE 16 /* Size of resulting digest in bytes */
The C structure must be named hash_state:
typedef struct { ... whatever state variables you need ... } hash_state;
There are four functions that need to be written: to initialize the algorithm's state, to hash a string into the algorithm's state, to get a digest from the current state, and to copy a state.
void hash_init(hash_state *self);
void hash_update(hash_state *self, unsigned char *buffer, int length);
PyObject *hash_digest(hash_state *self);
void hash_copy(hash_state *source, hash_state *dest);
Put #include "hash_template.c"
at the end of the file to
include the actual implementation of the module.