On Wed, Jan 3, 2018 at 1:48 AM, Jefferson Carpenter <[email protected]> wrote: > Hello, > > Is there any example code for using this library's SHA256 algorithm? What > is a HashWordType?
Checkout the wiki at https://www.cryptopp.com/wiki/Hash_Functions . Our pages on hash functions are kind of lame, but its about as difficult as: byte digest[SHA1::DIGESTSIZE]; byte message[] = { ... }; SHA1 hash; hash.Update(message, sizeof(message)); hash.Final(digest); > HashWordType sum; > SHA256::InitState(sum); > SHA256::Transform(sum, (const HashWordType*)data); > > but I'm totally unsure about just casting the data to a HashWordType pointer > in the 3rd line, and also not entirely sure whether / why InitState is > necessary to call before calling Transform. There's surely a correct way to > get your data into a HashWordType*, but unfortunately on the docs page I'm > looking at (https://www.cryptopp.com/docs/ref/class_s_h_a256.html) > HashWordType is not a hyperlink, it's just opaque text. Yeah, HashWordType is mostly internal except when it bleeds through like now. It is a word32 or word64, and it is specified in the template parameters. What you usually want to use is the base class members from HashTransformation . That interface gives you Update and Final. Also see https://www.cryptopp.com/docs/ref/class_hash_transformation.html . The interface you are seeing - InitState and Transform - is the "static" portion of IteratedHashWithStaticTransform. The short of it is, the interface allows use cases like MDC, where a user password is used as initial state, and the hash transformation is the traditional hash function. Also see https://www.cryptopp.com/docs/ref/mdc_8h_source.html . Jeff -- -- You received this message because you are subscribed to the "Crypto++ Users" Google Group. To unsubscribe, send an email to [email protected]. More information about Crypto++ and this group is available at http://www.cryptopp.com. --- You received this message because you are subscribed to the Google Groups "Crypto++ Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
