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

Add a streaming API for computing SHA-256. #9

Closed
ghost opened this issue Jun 1, 2021 · 1 comment
Closed

Add a streaming API for computing SHA-256. #9

ghost opened this issue Jun 1, 2021 · 1 comment
Assignees

Comments

@ghost
Copy link

ghost commented Jun 1, 2021

This API could be useful for computing checksum of a file without storing all of the file's data in the memory, or checksumming 2 strings together without concatenating them. Example -

const char *a = "hello,";
const char *b = " world!";
uint8_t hash[32];

sha256_ctx_t ctx;
sha256_init(&ctx);
sha256_update(&ctx, a, strlen(a));
sha256_update(&ctx, b, strlen(b));
sha256_final(&ctx, hash);
@amosnier amosnier self-assigned this Jun 5, 2021
@amosnier
Copy link
Owner

Implemented in 6e94ad4.

That is in fact a complete rewrite, but I think the resulting structure is significantly better, because the hash value is calculated in chunks anyway. Thanks a lot for this suggestion. Enjoy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant