Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

checksum each block #14

Open
pjrinaldi opened this issue Sep 20, 2022 · 0 comments
Open

checksum each block #14

pjrinaldi opened this issue Sep 20, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@pjrinaldi
Copy link
Owner

If I want to checksum each block compressed, I can use the following... (adler-32 used in ewf)

uint32_t Expert_Witness_Compression_CRC(
uint8_t *buffer,
size_t buffer_size,
uint32_t previous_key )
{
size_t buffer_iterator = 0;
uint32_t lower_word = previous_key & 0xffff;
uint32_t upper_word = ( previous_key >> 16 ) & 0xffff;

for( buffer_iterator = 0;
     buffer_iterator < buffer_size;
     buffer_iterator++ )
{
	lower_word += buffer[ buffer_iterator ];
	upper_word += lower_word;

	if( ( buffer_iterator != 0 )
	 && ( ( buffer_iterator % 0x15b0 == 0 )
	  || ( buffer_iterator == buffer_size - 1 ) ) )
	{
		lower_word = lower_word % 0xfff1;
		upper_word = upper_word % 0xfff1;
	}
}
return( ( upper_word << 16 ) | lower_word );

}

@pjrinaldi pjrinaldi added the enhancement New feature or request label Sep 20, 2022
@pjrinaldi pjrinaldi added this to the Feature Enhancements milestone Mar 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant