-
Notifications
You must be signed in to change notification settings - Fork 250
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
Finalising a sha256 has into an [u8; 32] #572
Comments
|
@WhyNotHugo regarding the diagnostics, here's a tracking issue for that: RustCrypto/traits#1069 |
Er, sorry, I meant |
|
You should be able to do something like: let mut buf = [0u8; 32];
digest.finalize_into(buf.as_ref()); (it might require However note that there's no cost to the "intermediate type" and these two are really equivalent. |
Thanks, I prefer to avoid adding generic-array as a direct dependency and using |
This is a good-to-know. Do you think it's worth including the example above in the README or in the docs? |
We are in the process of migrating to |
Nice, happy to see that there is also a path to move onto const-generic, that will definitely make things simpler on the API side :) |
I'm trying to generate the sha256 for some data into a
[u8; 32]
. I currently have some code that hashes my data into a string (e.g.: a hex representation of the hash):I'd like for this to return a
[u8;8]
instead, but I'm having a really hard time understanding what's going on beneath so many layers of abstractions.Sha256::new()
returns aCoreWrapper<CtVariableCoreWrapper<Sha256VarCore, UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, OidSha256>>
. It's not very clear to me whatCoreWrapper<CtVariableCoreWrapper<Sha256VarCore, UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, OidSha256>>
is or or how I'm supposed to reason about it beyond the basic examples in the README. The documentation forCoreWrapper
points toblock_buffer::BlockBuffer
, but that seems to be something used when implementing a hash function, not when using one.CoreWrapper<CtVariableCoreWrapper<Sha256VarCore, UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, OidSha256>>
implementsDigest
, which has afinalize_into
method, but that expects an un-exported type as input, so it doesn't seem to be what I'm looking for.Is there any way to write the digest directly into a
[u8;32]
?The text was updated successfully, but these errors were encountered: