Loading...
Searching...
No Matches
Fletcher32

Fletcher32 checksum algorithm. More...

Detailed Description

Fletcher32 checksum algorithm.

Files

file  fletcher32.h
 

Data Structures

struct  fletcher32_ctx_t
 Fletcher's 32 bit checksum context struct. More...
 

Functions

uint32_t fletcher32 (const uint16_t *buf, size_t words)
 Fletcher's 32 bit checksum.
 
void fletcher32_init (fletcher32_ctx_t *ctx)
 Initialize a fletcher32 context.
 
void fletcher32_update (fletcher32_ctx_t *ctx, const void *data, size_t words)
 Incrementally update the fletcher32 context with new data.
 
uint32_t fletcher32_finish (fletcher32_ctx_t *ctx)
 Finalize the checksum operation and return the checksum.
 

Function Documentation

◆ fletcher32()

uint32_t fletcher32 ( const uint16_t *  buf,
size_t  words 
)

Fletcher's 32 bit checksum.

found on http://en.wikipedia.org/w/index.php?title=Fletcher%27s_checksum&oldid=661273016#Optimizations

Note
the returned sum is never 0
pay attention to the words parameter buffer containing 16 bit words, not bytes.
Parameters
bufinput buffer to hash
wordslength of buffer, in 16 bit words
Returns
32 bit sized hash in the interval [1..2^32]

◆ fletcher32_finish()

uint32_t fletcher32_finish ( fletcher32_ctx_t ctx)

Finalize the checksum operation and return the checksum.

Parameters
[in]ctxfletcher32 context
Returns
32 bit sized hash in the interval [1..2^32]

◆ fletcher32_init()

void fletcher32_init ( fletcher32_ctx_t ctx)

Initialize a fletcher32 context.

Multi-part version of fletcher32.

Parameters
[in]ctxfletcher32 context to initialize

◆ fletcher32_update()

void fletcher32_update ( fletcher32_ctx_t ctx,
const void *  data,
size_t  words 
)

Incrementally update the fletcher32 context with new data.

Can be an arbitrary amount of times with new data to checksum.

Note
words is the number of 16 bit words in the buffer
data should contain an integer number of 16 bit words
Parameters
[in]ctxfletcher32 context
[in]dataData to add to the context
[in]wordsLength of the data in 16 bit words