-
Notifications
You must be signed in to change notification settings - Fork 297
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 Digest::input_hashable method #333
base: master
Are you sure you want to change the base?
Conversation
A method to Digest to allow it to take data of any type that implements Hash. Add a default impl for the method.
I'm surprised this didn't exist already which makes me suspect I'm missing some obvious reason why it shouldn't exist. But anyway, I've found this very useful so I'm leaving this PR here as a suggestion. |
@DaGenix Any interest in this? |
@DaGenix Bump. I'm using a local, patched version of rust-crypto that has this for a project that I'm thinking of publishing on crates.io. I don't really wanna have to remove it because it's quite useful. |
Would love seeing something like this merged too. (Didn't review the PR yet) |
You guys saw the other two open pull requests : #373 #294 If I understand correctly, this pull request allows one to use a cryptographic hash supplied by rust-crypto wherever one might wish to use a regular Rust hash, yes? I think that's okay for security, but.. It'll kill the performance of many tools that expect non-cryptographic hash functions, likely including Rust's HashMap. I have not examined their Robin Hood hashing strategy, but they do keep a As an example, I'm considering writing a cuckoo hashing based alternative for HashMap that I plan to use to store secret key material indexed by their hashes. It requires a cryptographic has for the public identifier key while the value remains the secret key. It need not store this public identifier key that acts as the key into the hash table, but it does need a small fingerprint of it from which to do it's cuckoo egg thang. |
Oh wait. I just saw you have finish returning |
That's probably a better idea really. The point of this |
@@ -11,13 +11,19 @@ | |||
use std::iter::repeat; | |||
use std::hash::{Hash, Hasher}; | |||
|
|||
/* | |||
* The purpose of this type is to implement `Hasher` so that it can extract data from any type | |||
* which implements `Hash` and write the dataa to a `Digest`. This type is private to this module |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: "dataa"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
We could write an RFC for a |
Or maybe someone need to byte the bullet and try to standardize something better than the ByteOrder create for doing that sort of thing. Edit : I mean, I suppose the underlying issue here is the need to hash larger integer types, but that brings in endianness issues. |
Anyways this |
I just opened rust-lang/rfcs#1768 which I believe is relevant. |
Appears If Also endianness can make a mess of things if one gets sloppy here. It's easy enough to patch if you wrap the Hasher as I mentioned in rust-lang/rfcs#1666 (comment) |
Just uploaded a quick and dirty wrapper crate to address endiannes in hashing. I suppose it won't work with private |
A method to
Digest
to allow it to take data of any type that implementsstd::hash::Hash
. Add a default impl for the method.