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 Hash_Function::final_truncated() #4537

Open
reneme opened this issue Jan 9, 2025 · 0 comments
Open

Add Hash_Function::final_truncated() #4537

reneme opened this issue Jan 9, 2025 · 0 comments

Comments

@reneme
Copy link
Collaborator

reneme commented Jan 9, 2025

For certain applications it would actually be nice if Hash_Function could truncate internally. Something like:

void Hash_Function::final_truncated(std::span<uint8_t> out) {
   if(out.size() == output_length()) {
      final(out);
   } else {
      const auto h = final();
      copy_mem(out, std::span{h}.first(out.size()));
   }
}

Or perhaps even pass the shorter span down into the individual hash functions to partially-copy straight from the hash's internal state (if possible).

Originally posted by @reneme in #4455 (comment)

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

1 participant