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

reuse the hasher after finalized? #429

Closed
ibigbug opened this issue Nov 4, 2022 · 5 comments
Closed

reuse the hasher after finalized? #429

ibigbug opened this issue Nov 4, 2022 · 5 comments

Comments

@ibigbug
Copy link

ibigbug commented Nov 4, 2022

it seems the finalize() will consume the hasher:

Retrieve result and consume hasher instance.

https://docs.rs/md-5/latest/md5/trait.Digest.html#tymethod.finalize

how ever it doesn't reset the state.

how to reuse and write more data into the hasher after finalized()?

@tarcieri
Copy link
Member

tarcieri commented Nov 4, 2022

Use finalize_reset

@tarcieri tarcieri closed this as completed Nov 4, 2022
@ibigbug
Copy link
Author

ibigbug commented Nov 5, 2022

i think i didn't make it clear - it's not about resetting the state. i.e. continue to write more data after finalize() and finalize() again with more data.

@tarcieri
Copy link
Member

tarcieri commented Nov 5, 2022

Then you want to Clone prior to finalization

@burdges
Copy link

burdges commented Nov 5, 2022

Also, merlin was more designed for this sort of thing.

As an aside, rust maybe needs some replace_with method that makes reset methods unnecessary by ensuring zero copies: rust-lang/rfcs#2884 (comment)

@burdges
Copy link

burdges commented Nov 5, 2022

It appears https://docs.rs/replace_with/ provides equivalent functionality to the *reset methods.

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

No branches or pull requests

3 participants