Signature: void *r30s_new(size_t bits, size_t steps)
Param (bits): The size of the internal state in bits.
Param (steps): The number of Rule 30 steps per bit.
Returns: Pointer to sponge.
This function allocates and initializes a sponge.
Signature: void *r30s_new_default()
Returns: Pointer to sponge
Signature: void r30s_absorb_bit(void *sp, uint8_t bit)
Param (sp): Sponge pointer
Param (bit): The bit to absorb
Returns: Nothing
Signature: void r30s_absorb_bit(void *sp, uint8_t byte)
Param (sp): Sponge pointer
Param (byte): The byte to absorb
Returns: Nothing
Below are some examples.
size_t hash_cstr(const char *str) {
size_t hash;
void *sp = r30s_new_default();
r30s_absorb_cstr(sp, str);
r30s_squeeze_buf(sp, &hash, sizeof(hash));
return hash;
}
If you do not want the library to perform dynamic memory allocations, you can define R30S_NOMALLOC
. This will remove the r30s_new
and r30s_new_default
functions. Aside from these constructors, there is no memory allocation anywhere else in the library.
Gokberk Yaltirakli - https://www.gkbrk.com/