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

What's the best Digest trait? #15

Closed
cakoose opened this issue Feb 15, 2017 · 4 comments
Closed

What's the best Digest trait? #15

cakoose opened this issue Feb 15, 2017 · 4 comments
Labels

Comments

@cakoose
Copy link

cakoose commented Feb 15, 2017

Both the rust-crypto and digest crates have a Digest trait. They're both listed as being authored by "The Rust-Crypto Project Developers".

If I'm defining a new hash algorithm, which trait should I implement?

@newpavlov
Copy link
Member

newpavlov commented Feb 15, 2017

In your case it's better to use Digest trait from the digest crate, as I don't think you want to pull the whole rust-crypto as your dependency just for one trait. Also look into digest-buffer too, you may find it convenient.

One thing to note: Digest trait probably will change a bit in the future (see #14), I will publish the new version under 0.5, but I think it's better for you to know about it.

Any chance that your hash implementation could become part of this project in the future?

UPD: Ah, you want to write Dropbox Content Hasher if I am not mistaken and add Rust example to dropbox-api-content-hasher. Am I right?

@cakoose
Copy link
Author

cakoose commented Feb 15, 2017

Yup, it's a non-standard hash just for the Dropbox API, so probably not worth including in this project :-)

I'll go ahead and use the digest crate's trait for now. Thanks!

@cakoose cakoose closed this as completed Feb 15, 2017
@newpavlov
Copy link
Member

BTW you can write and publish crate dropbox-content-hasher (or with similiar name) and use it in your example instead of publishing source codes with implementation of this hash, I think it will be more convenient for potential users. Also note that generic-array (return type in the Digest trait) implements LowerHex and UpperHex, so you can simplify conversion to hex by using standard formatting functionality.

@cakoose
Copy link
Author

cakoose commented Feb 15, 2017

The goal is to actually have this code as part of the Dropbox API SDKs. It's just that those aren't ready yet, so we decided to publish code samples for early adopters to copy/paste for now.

Thanks for the hex tip. I'll update the code.

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

No branches or pull requests

2 participants